0% found this document useful (0 votes)
9 views5 pages

QuestionPaper LabTestMakeup

The document outlines the instructions and problem statements for an online programming test for the CS F111 course at Birla Institute of Technology & Science, Pilani. It includes general instructions for submission, guidelines for attempting the test, and specific programming tasks for seven questions, each requiring the implementation of functions in C to solve various problems. The test is binary marked, and students must adhere to strict submission protocols to avoid penalties.

Uploaded by

f20240812
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

QuestionPaper LabTestMakeup

The document outlines the instructions and problem statements for an online programming test for the CS F111 course at Birla Institute of Technology & Science, Pilani. It includes general instructions for submission, guidelines for attempting the test, and specific programming tasks for seven questions, each requiring the implementation of functions in C to solve various problems. The test is binary marked, and students must adhere to strict submission protocols to avoid penalties.

Uploaded by

f20240812
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Birla Institute of Technology & Science, Pilani

First Semester 2023-24


CS F111 – Computer Programming Online Programming Test
SET MAKEUP ANUJ WAGH
==================================================================================
03/12/2023 Max. Marks: 77M Max Duration: 135 mins
==================================================================================

General Instructions
● This paper consists of seven questions (Q1, Q2, Q3, Q4, Q5, Q6 and Q7), each carrying 11 marks.
● The paper is binary marked, so if your answer exactly matches the answer expected in the main.c
file for that specific question, you get 11 marks, else you get 0 marks for that question.
●Read all the instructions and the problem statements very carefully before attempting.
● Carefully follow the submission instructions mentioned below before uploading your solution on
●the DomJudge portal.
If you submit multiple submissions, only the latest one will be considered for evaluation. Whatever
you submit on the DomJudge portal will be considered as final. It is your responsibility to make
sure that you are submitting the correct file. Later, if some student claims that he/she has
mistakenly submitted the wrong file, we won’t be entertaining any such request and we will
evaluate based on whatever is submitted on the DomJudge portal.
● After submitting, on the portal you have an option to verify that you have submitted the correct
files. Ensure you verify it before the countdown timer expires.

Instructions to attempt the test


- Create a new directory with your 13 digit ID number, e.g. if your ID is 2023A2PS0001P, create a
directory with this ID.
- Download the Set_Pink.zip file from your contest in Domjudge portal and extract and paste all the
files into this directory.
- Now, right-click on the file “[Link]” which was just copied in the new directory and change
the permissions/properties of the file to allow it to Execute. Do not change permissions of any other
file that you copied.
- While attempting your questions, you are not allowed to modify the files [Link], main.c, f1.h
f2.h, f3.h,…,f7.h except giving execute permission to [Link]. You should neither make any
changes to the function parameters, nor to the return types of any of the functions in this file.
- You can only modify f1.c, f2.c, f3.c,...,f7.c.
- Now start attempting the questions below.
- To compile and execute, you must use [Link] only, e.g., if you want to compile and test your
solution for Q1, you must run the following on the terminal: ./[Link] 1
- Similarly, for all the other questions.
**Strictly do not write any printf/scanf functions in f1.c, f2.c, … f7.h. In case you write for
debugging purpose, you must remove them before your final submission on DomJudge.
**Strictly do not change the return type or the function parameters of the functions in f1.c, f2.c,
f3.c,..., f7.c
If you do any of the above dont’s you will definitely incur a heavy penalty.

Submission Instructions
Your final submission should be a zip folder with the name as your 13-digit ID number, e.g.,
2023A2PS0001P with 16 files in all (namely [Link], main.c, f1.c, f2.c,..., f7.c, f1.h, f2.h,..., f7.h).

Page 1 of 5
Problem Statements

Q1. Write a C program to rotate clockwise (right) the array by specifying a range of elements instead
of the entire array. In the main function, you are given a code prompting the user to create an array
Arr of size n and to store the user's input. After that, take an unsigned integer rotateBy from the
user. Your task is to code the provided function void rotateArray(int arr[], int n, int rotateBy, int
start, int end) in f1.c to rotate the Arr by a given number of positions and by specifying a range of
elements. Your code should satisfy the following samples.
Sample 1:

Enter the size of the array: 5

Enter the elements of the array: 1 2 3 4 5

Enter the number of positions to rotate: 2

Enter the range [start, end] (0-indexed): 1 3

Rotated Array: 1 4 3 2 5

Sample 2:

Enter the size of the array: 6

Enter the elements of the array: 5 6 7 8 9 10

Enter the number of positions to rotate: 0

Enter the range [start, end] (0-indexed): 2 5

Rotated Array: 5 6 7 8 9 10

Sample 3:

Enter the size of the array: 4

Enter the elements of the array: 10 20 30 40

Enter the number of positions to rotate: 3

Enter the range [start, end] (0-indexed): 0 2

Rotated Array: 10 20 30 40

Q2. Write a C program to find the count of the maximum occurring character in a string. In the main
function, you are given a code prompting the user to enter a string as input. Your task is to code the
provided function void findMaxOccurringChar(char inputString[], char *maxChar, int *maxCount)
in F5.c. After processing, it should output the count of the maximum occurring character in a string.
Your code should satisfy the following samples.
Sample1:

Page 2 of 5
Enter a string: programming

Maximum occurring character: m

Count of the maximum occurring character: 2

Sample2:

Enter a string: hello world

Maximum occurring character: l

Count of the maximum occurring character: 3

Q3. In this question, you are given an array of strings words and a character x. You need to identify
the words in this string that contain the character x and capture the indices of those words in the
array arr_indices. Note that the indices in the array arr_indices should be in non-decreasing order as
shown in the samples below. Complete the function findWordsContaining in f3.c.
Sample 1:

Enter the number of words to be entered into an array of strings: 2

Enter word 1: bits

Enter word 2: pilani

Enter the character to be passed: a

Printing array containing indices of the strings: 1

Sample 2:

Enter the number of words to be entered into an array of strings: 3

Enter word 1: abc

Enter word 2: bac

Enter word 3: ccc

Enter the character to be passed: c

Printing array containing indices of the strings: 0 1 2

Sample 3:

Enter the number of words to be entered into an array of strings: 3

Enter word 1: abc

Enter word 2: bcd

Enter word 3: aaa

Page 3 of 5
Enter the character to be passed: z

Printing array containing indices of the strings: No words found

Q4. Given an array of integers nums, calculate the pivot index of this array. The pivot index is the
index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the
numbers strictly to the index's right.

If the index is on the left edge of the array, then the left sum is 0 because there are no elements to
the left. This also applies to the right edge of the array.
Return the leftmost pivot index. If no such index exists, return -1. Complete the function pivotIndex
in f4.c.
Sample 1:

Enter the size of the array: 5

Enter the elements of the array: 3 0 1 0 2

The pivot index is: 1

Sample 2:

Enter the size of the array: 3

Enter the elements of the array: 2 1 -1

The pivot index is: 0

Sample 3:

Enter the size of the array: 4

Enter the elements of the array: 1 2 3 4

The pivot index is: No such index exists

Q5. In this question, you are required to find the determinant of a 3x3 matrix matrix. Complete the
function calculateDeterminant in f5.c.
The formula for calculating the determinant is the following where a11, a22… correspond to the
elements of the matrix with a11 being 0th row and 0th column in a 2D array.
det(A) = a11(a22a33 - a23a32) - a12(a21a33 - a23a31) + a13(a21a32 - a22a31)

Sample 1:

Enter the elements of the 3x3 matrix:

1 2 3 4 5 6 -1 -1 -1
Determinant of the matrix: 0
Sample 2:

Page 4 of 5
Enter the elements of the 3x3 matrix:

1 2 3 -2 -8 -3 4 3 2
Determinant of the matrix:55

Q6 & Q7. In the main function, you already have code to prompt the user to enter the size of the two
linked lists, num1 and num2. Then, using a for loop, you take input from the user, you have to create
the linked list using the insertInSortedOrder function (the elements need to be in sorted order).
Following that, you invoke the function mergeSortedLists, passing two heads of the linked list, list1,
and list2, as an argument. This mergeSortedLists function merges the two linked lists into a sorted
linked list.
Complete the following functions :
a. insertInSortedOrder
b. mergeSortedLists
Your task is to code the functions insertInSortedOrder and mergeSortedLists in f6.c and f7.c,
respectively, to satisfy the following samples. You should attempt Q7 (f7.c) only after attempting Q6
(f6.c).
Sample 1:
Enter the number of elements for list 1&2: 3 5

Enter 3 elements for list 1 in sorted order: 101 97 50

Enter 5 elements for list 2 in sorted order: 305 103 89 77 20

First sorted list: 50 -> 97 -> 101 -> NULL

Second sorted list: 20 -> 77 -> 89 -> 103 -> 305 -> NULL

Merged sorted list: 20 -> 50 -> 77 -> 89 -> 97 -> 101 -> 103 -> 305 -> NULL
Sample 2:
Enter the number of elements for list 1&2: 6 5

Enter 6 elements for list 1 in sorted order: 33 27 16 11 7 4

Enter 5 elements for list 2 in sorted order: 50 43 37 24 13

First sorted list: 4 -> 7 -> 11 -> 16 -> 27 -> 33 -> NULL

Second sorted list: 13 -> 24 -> 37 -> 43 -> 50 -> NULL

Merged sorted list: 4 -> 7 -> 11 -> 13 -> 16 -> 24 -> 27 -> 33 -> 37 -> 43 -> 50 -> NULL

-------------------------------------------------------------------------------------------------------------------------------------

Page 5 of 5

You might also like