Download as pdf
Download as pdf
You are on page 1of 2
BIRLA INSTITUTE OF TECHNOLOGY AND SCIENCE, PILANI DEPARTMENT OF COMPUTER SCIENCE AND INFORMATION SYSTEMS COMPUTER PROGRAMMING (CSF 111) 1ST SEMESTER 2021-22 MID-SEMESTER EXAMINATION (CLOSED BOOK) MAX MARKS 50 TIME: 90 MINUTES Instructions: 1. Answer all the parts of a question together in the answer sheet. Answers at separate places will not be accepted, Please do not write any information irrelevant to the question, 1. Explain what will be the output of the following commands? (3*2=6 Marks] a. grep -i 'VaRiabLe’ code.c| grep -vc int b. head code.c| tail -6 | grep float © grep -n's$' code.c 2. Answer the following: [5*2 = 10 Marks] a, Find the value of a positive integer A, given that A? = (B491),4. Convert A to its equivalent binary form, b. Find the base of the number system whose numbers 402, 20, and 17.1 satisfy the equation 402/20 = 17.1. 3. Aprocessor consists of carry, overflow, and sign bits as part of its internal record, What will be the updated status of these three bits (carry, overflow, and sign bits) after performing addition of two 2's complement numbers 01001101 and 11100011? [6 Marks} 4, Fill in the blank (denoted by ) using a single operator, variable or constant in order to get the desired output: [3*2= 6M] a. int a= @, b= 0, x; x =a || b-- (a = b = 55); printf("%d %d Xd\n", a, b, x); // the desired output of the printfstatementis 0 -1 0 b. int a= 0, b= 0, 2; Zz = +a && b-- || (a = b = ); printf("%d %d\n", a, b); // the desired output of the printfstatement is: -1 -1 5. Create a flowchart for an algorithm that takes three numbers as input from the user ea prints the largest of them, [6 Marks} 6. Briefly answer the following questions: [2*4 = 8 Marks] a. When we save a program with “c” extension, where does the program reside? b. When we try to run the program, where is the program loaded and executed? € What are various types of memory ina computer? d. See the code given below: int a = 5; float b = (float)a; printf("%f\n", b); if(a == b) printf("Yes"); else printf("No"); The output of the firstprintfis 5.000000, With a one-line reasoning, explain what gets printed next (‘Yes’ or ‘No'), and why? (Note: No marks without proper reasoning) 7. Write a C program that reads a number, n, from the user as input and if the entered number isan even number then your program just prints that number. Otherwise (that means if the entered number is an odd number), your program should invert the least number of bits in the binary representation of n so that: that ne > n. Finally, your program should print ne. [8 Marks) - END OF THE PAPER

You might also like