Question Paper Code : 20861
B.E./B.Tech. DEGREE EXAMINATIONS, NOVEMBER/DECEMBER 2023.
Second Semester
Computer Science and Engineering
CS 3251 — PROGRAMMING IN C
(Common to : Computer Science and Engineering (Data Science)/Electrical and Computer Engineering/Computer Science and Engineering (Artificial Intelligence and Machine Learning)/Computer Science and Engineering (Cyber Security)/Computer and Communication Engineering/Information Technology)
(Regulations 2021)
Answer ALL questions.
PART A — (10 × 2 = 20 marks)
- 1.
"Keywords cannot be used as Identifiers" - Justify the correctness of the statement.
- 2.
Distinguish between 'While' and 'Do-While' looping constructs with one example.
- 3.
Give an example for initialization of a 2D array with a set of values.
- 4.
Write any two string handling functions in C with their syntax and purpose.
- 5.
Find the output of the following code. int main() { int a = 10, b = 20; change(&a, b); printf("\n Inside Main : %d %d\n", a,b); return 0; } void change(int *p, int q) { *p = *p*3; q = q*4; printf("\n Inside function : %d %d", *p, q); }
- 6.
If p is a pointer to a float array a[10] with base address 1000, then what is the value of p after executing the statement p++; ? Justify your answer.
- 7.
Differentiate 'Structure' and 'Union'.
- 8.
Illustrate with an example for each, the following operators with regard to pointers and structures. &, *, . , ->
- 9.
What will be the values for argc and argv[ ] when the input "run with my values" is passed as command line arguments?
- 10.
Name any two functions used in Random access files and specify their use in C programming.
PART B — (5 × 16 = 80 marks)
- 11.(a)
- (i)Evaluate the following expressions using operator precedence rule. Explain the order of execution of operators. (8*3-4)+(5%5? 3 : -9) + 5 - 20 / 10; a * b + (c / d) - 2 ^ 2 - (e + 4) where a = 2, b = 3, c = 8, d = 2, e = 5.(6)
- (ii)Elaborate the various Data types in C with suitable examples.(10)
- Or
- (b)
- (i)Find the output of the following C code. Discuss the steps of execution. for(i=1,j=1; i<=10; ++i, ++j) { if (i == 3) { continue;} else { if (j== 4) {break;} else { printf("\ I am in loop, the values of I and J are: %d, %d", i,j); } } }(4)
- (ii)Write a C program to get age and vaccination detail as input. Print "Senior Citizen and Eligible for Booster" if age > 60 and vaccination input as '2'. Otherwise print "Below 60, and Eligible for Vaccination". Use Conditional Operator.(5)
- (iii)Is it possible to convert 'if-else' ladder to 'switch.....case' statement? If yes, illustrate with an example. If no, justify the reason.(7)
- 12.(a)
- (i)Write the string handling function used to do the following. (2+2+2+2) If first name, last name and middle name are given as input, display it as full name. Display the number of characters in full name. Convert the first name into capital letters and last name into small letters. Print the full name in reverse order.(8)
- (ii)In a restaurant, the tables are arranged in a room row-wise order. A waiter is assigned to serve food for each row. Write a C program to find the highest bill served by each waiter.(8)
- Or
- (b)
- (i)Explain binary search technique with an example. How to search for the key '14' in the array of numbers 12, 56, 90, 14, 19, 63, 88, 25, 37, 49, 110. (3+4)(7)
- (ii)In a Marathon, there are 5 tracks. In each track 'n' number of participants are placed. Find the youngest and oldest participant in each track.(9)
- 13.(a)
- (i)Write a C program to create two 2D arrays using array of pointers. First 2D array consists of a list of employee names and the second 2D array consists of their designation. Your code should display the designation when name is entered.(13)
- (ii)Give an example for a function that receives parameters and returns no value.(3)
- Or
- (b)
- (i)Create an array of lucky ticket numbers announced for prize bonanza. Get a ticket number and check it for prize and display the result. Use pointer to array concept.(12)
- (ii)Differentiate between 'Pass by value' and 'Pass by reference' with an example.(4)
- 14.(a)
- (i)Give an example for the following: (1) Nested structure (2) Self-referential structure(6)
- (ii)List the operations on Linked list. Explain insertion at end and deletion at beginning of a Singly linked list.(6)
- (iii)Distinguish between calloc( ) and malloc( ) functions.(4)
- Or
- (b)
- (i)Consider a structure 'furniture' that includes the information about furniture in a shop. Write a function call statement that has the argument as a pointer to the structure and number of furniture. Also, provide the corresponding function definition statement that receives the arguments.(8)
- (ii)Write the function body that prints the details of 'n' furniture.(4)
- (iii)Use 'typedef to define 'furniture' as array of structures.(4)
- 15.(a)
- (i)Mention the purpose of fseek( ) function in random files.(3)
- (ii)When to use fread( ) and fwrite( ) functions in file processing?(5)
- (iii)List down the modes in which a C file can be opened. Specify the purpose of each mode.(5)
- (iv)What is the use of feof( ) function?(3)
- Or
- (b)
Write a C program to create a binary file in C named "application.txt" that has the data such as citizen name, aadhar number, pan number, employment, gender and age. Filter the application by analyzing the gender and employment and move all the male applicants who are self-employed into another file called "reject.txt". Assume minimum 10 candidates.