It End Sem
It End Sem
Note: If you answer more than two, ONLY THE FIRST TWO in sequence will be evaluated,
Q1:
It is desired to count the number of ‘0’ bits and the number of ‘1’ bits in the binary equivalent
of a given integer of data type int. For example, if the given integer is 17 and the machine
assigns one byte for data type int, we say that there are SIX ‘0’ bits and TWO ‘1’ bits
because 1710 = 000100012 . Note that the size of int varies from processor to processor.
• Read an integer of data type int through the keyboard and determine the number of
bytes assigned to the data type.
• Display the integer read and the number of bytes assigned to int
• Count the number of ‘0’ bits and ‘1’ bits using “for” loop statement
• Display the results with appropriate messages.
Q2:
The following data concerning the marks obtained by five students in different exams is
stored in a file called “marks.txt”, which is already stored in the directory /iiitv/IT101 in the
D drive of a computer.
Write a C program to read the above data into a 2D array using file processing commands.
The program should determine the smallest and largest number in each column (except the
Student Id column) and print the results in an appropriate form with proper headings.
Q3:
Write a C program to print the following triangular pattern of size N, where N is the number
of rows. The pattern obtained for N = 6 is as shown below.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
Each element in the 1st and 2nd rows is fixed as 1. The elements of the “third row and
downward” are calculated as the sum of the element directly above it and the element to the
left of the element directly above it.
For example:
In the 5th row 2nd element is : 4 = 3 (element directly above) + 1(left of the element
directly above)
In the 5th row 3rd element is : 6 = 3 (element directly above) + 3(left of the element
directly above)
------END------