You are on page 1of 3

Programming and Data Structures, Spring 2011,Quiz 1 Total Marks: 30 Section I Name: Roll Number: Note: Please answer

all questions neatly with workings, marks will be deducted if there are no workings, please specific the number for the answers, ie Part A, 1 etc Part A (10 marks,1 marks for each question) 1. Give an example of an input and output statement in C ? 2. What is the range of integers that can be stored in a computer? 3. What is the size of a float data type and a long data type? 4. What will be the result of 2/7.0? 5. What will be the result of 7 % (- 2)? 6. Please provide the following missing numbers: Decimal 97 Binary 110111 BA 24 44 Hexadecimal Octal

Part B(10 marks, 2 marks for each question) Please provide the Output to Each of these code snippets, assume the #include statements and getchar() etc are there

1|P ag e

1.

int main( ) { int i = 1, j = 1 ; for ( ; ; ) { if ( i > 5 ) break ; else j += i ; printf ( "\n%d", j ) ; i += j ; } }

2. int main(){ int i=0; if(i==0){ i=((5,(i=3)),i=1); printf("%d",i); } else printf("equal"); getchar(); } 3. int main(){ int a=25;

printf("%o %x",a,a); getchar(); }

2|P ag e

4. int main() { int i=j=0;

for (i=j=0; i<10 && j<10 ; i++, j+=2) { if (j == 2); printf ("j has reached 4\n"); } printf("terminal values for i and j are %d %d\n", i, j); getchar(); } 5. int main() {

char small_string[5] = {'F','O', 'O'}; printf("small_string is: %s and length is %d and size is %d\n", small_string, strlen(small_string), sizeof(small_string)); //why? getchar(); } Section C(10 marks,5 marks for each question) Please draw flow chart and hand write the following programs 1. convert a octal number to binary (hint: use quotient and remainder).

2. If the three sides of a triangle are entered through the keyboard, write a program to check

whether the triangle is valid or not. (Hint: The triangle is valid if the sum of two sides is greater than the largest of the three sides.)

3|P ag e

You might also like