Placement Papers: Mistral 2006

Get top class preparation for competitive exams right from your home: get questions, notes, tests, video lectures and more- for all subjects of your exam.

Mistral Solutions

C Section

  1. What does the following program print? #include < stio. h > int sum, count; void main (void) {< BR > for (count = 5; sum += --count;) printf ( “% d” sum) ;}
    1. The pgm goes to an infinite loop
    2. Prints 4791010974
    3. Prints 4791001974
    4. Prints 5802112085
    5. Not sure
  2. What is the output of the following program? #include < stdio. h > void main (void) {int i; < BR > for (i = 2; i ⇐ 7; i ++) printf ( “% 5d” fno () ) ;} fno () {staticintf1 = 1, f2 = 1, f3; return (f3 = f1 + f2, f1 = f2, f2 = f3) ;}
    1. produce syntax errors
    2. 2 3 5 8 13 21 will be displayed
    3. 2 2 2 2 2 2 will be displayed
    4. none of the above
    5. Not sure
  3. What is the output of the following program? #include < stdio. h > void main (void) {int x = 0 × 1234; int y = 0 × 5678; x = x & 0 × 5678; y = y|0 × 1234; x = xy; printf ( “% x⧵t” x) ; x = x|0 × 5678; y = y & 0 × 1234; y = yx; printf ( “% x⧵t” y) ;}
    1. bbb3 bbb7
    2. bbb7 bbb3
    3. 444c 4448
    4. 4448 444c
    5. Not sure
  4. What does the following program print? #include < stdio. h > void main (void) {int x; x = 0; if (x = 0) printf ( “Value of x is 0” ) ; else printf ( “Value of x is not 0” ) ;}
    1. print value of x is 0
    2. print value of x is not 0
    3. does not print anything on the screen
    4. there is a syntax error in the if statement
    5. Not sure
  5. What is the output of the following program? #include < stdio. h > #include < string. h > int foo (char ⚹) ; void main (void) {char arr [100] = { “Welcome to Mistral” } ; foo (arr) ;} foo (char ⚹ x) {printf ( “% d⧵t” strlen (x) ) ; printf ( “% d⧵t” sizeof (x) ) ; return0;}
    1. 100 100
    2. 18 100
    3. 18 18
    4. 18 2
    5. Not sure
  6. What is the output of the following program? #include < stdio. h > display () {printf ( “⧵n Hello World” ) ; return 0;} void main (void) {int (⚹ func_ptr) () ; func_ptr = display; printf ( “⧵n % u” func_ptr) (⚹ func_ptr) ; () ;}
    1. it prints the address of the function display and prints Hello World on the screen
    2. it prints Hello World two times on the screen
    3. it prints only the address of the fuction display on the screen
    4. there is an error in the program
    5. Not sure
  7. What is the output of the following program? #include < stdio. h > void main (void) {int i = 0; char ch = ‘A’ do putchar (ch) ; while (i ++ < 5 |+ + ch ⇐ ‘F’ ) ;}
    1. ABCDEF will be displayed
    2. AAAAAABCDEF will displayed
    3. character ‘A’ will be displayed infinitely
    4. none
    5. Not sure
  8. What is the output of the following program? #include < stdio. h > #define sum (a, b, c) a + b + c #define avg (a, b, c) sum (a, b, c) /3 #define geq (a, b, c) avg (a, b, c) >= 60 #define lee (a, b, c) avg (a, b, c) ⇐ 60 #define des (a, b, c, d) (d == 1? geq (a, b, c) : Lee (a, b, c) ) void main (void) {int number = 70; char ch = ‘0’ float f = 2.0; if des (number, ch, f, 0) puts ( “lee.” ) ; else puts ( “geq …” ) ;}
    1. syntax error
    2. geq … Will be displayed
    3. lee. Will be displayed
    4. none
    5. Not sure
  9. Which of the following statement is correct?
    1. sizeof ( ‘⚹’ ) is equal to sizeof (int)
    2. sizeof ( ‘⚹’ ) is equal to sizeof (char)
    3. sizeof ( ‘⚹’ ) is equal to sizeof (double)
    4. none
    5. Not sure
  10. What does the following program print? #include < stdio. h > char ⚹ rev (int val) ; void main (void) {extern char dec [] ; printf ( “% c” ⚹ rev) ;} char ⚹ rev (int val) {char dec [] = “abcde” return dec;}
    1. prints abcde
    2. prints the address of the array dec
    3. prints garbage, address of the local variable should not returned
    4. print a
    5. Not sure
  11. What does the following program print? void main (void) {int i; static int k; if (k == ‘0’ ) printf ( “one” ) ; else if (k == 48) printf ( “two” ) ; else printf ( “three” ) ;}
    1. prints one
    2. prints two
    3. prints three
    4. prints one three
    5. Not sure
  12. What does the following program print? #include < stdio. h > void main (void) {enum sub {chemistry, maths, physics} ; struct result {char name [30] enum sub sc;} ; struct result my_res; strcpy (my_res. Name, “Patrick” ) ; my_res. Sc = physics; printf ( “name:% s⧵n” my_res. Name) ; printf ( “pass in subject:% d⧵n” my_res. Sc) ;}
    1. name: Patrick
    2. name: Patrick
    3. name: Patrick pass in subject: 2 pass in subject: 3 pass in subject: 0
    4. gives compilation errors
    5. Not sure
  13. What does printf ( “% s” _FILE_) ; and printf ( “% d” _LINE_) ; do?
    1. the first printf prints the name of the file and the second printf prints the line no: Of the second printf in the file
    2. _FILE_ and _LINE_ are not valid parameters to printf function
    3. linker errors will be generated
    4. compiler errors will be generated
    5. Not sure
  14. What is the output of the following program? #include < stdio. h > void swap (int x, int y, int t) {t = x; x = y; y = t; printf ( “x inside swap:% d⧵t y inside swap:% d⧵n” x, y) ;} void main (void) {int x; int y; int t; x = 99; y = 100; swap (x, y, t) ; printf ( “x inside main:% d⧵t y inside main:% d” x, y) ;}
    1. x inside swap: 100 y inside swap: 99 x inside main: 100 y inside main: 99
    2. x inside swap: 100 y inside swap: 99 x inside main: 99 y inside main: 100
    3. x inside swap: 99 y inside swap: 100 x inside main: 99 y inside main: 100
    4. x inside swap: 99 y inside swap: 100 x inside main: 100 y inside main: 99
    5. Not sure
  15. Consider the following statements:
    1. “while loop” is top tested loop
    2. “for loop” is bottom tested loop
    3. “do-while loop” is top tested loop
    4. “while loop” and “do-while loop” are top tested loops.

    Which among the above statements are false?

    1. i only
    2. i & ii
    3. iii & i
    4. ii, iii & iv
    5. Not sure
  16. Consider the following piece of code: Char ⚹ p = “MISTRAL” printf ( “% c⧵t” ⚹ (++ p) ) ; p-= 1; printf ( “% c⧵t” ⚹ (p ++) ) ; Now, what does the two printf՚s display?
    1. M M
    2. M I
    3. I M
    4. M S
    5. Not sure
  17. What does the following program print? #include < stdio. h > struct my_struct {int p: 1; int q: 1; int r: 6; int s: 2;} ; struct my_struct bigstruct; struct my_struct1 {char m: 1;} ; struct my_struct1 small struct; void main (void) {printf ( “% d % d⧵n” sizeof (bigstruct) , sizeof (smallstruct) ) ;}
    1. 10 1
    2. 2 2
    3. 2 1
    4. 1 1
    5. Not sure
  18. Consider the following piece of code: FILE ⚹ fp; fp = fopen ( “myfile. Dat” “r” ) ; Now fp points to
  19. What does the following program print? #include < stdio. h > #define SQR (x) (x ⚹ x) void main (void) {int a, b = 3; a = SQR (b + 2) ;}
  20. What does the declaration do? int (⚹ mist) (void ⚹ , void ⚹)
    1. declares mist as a function that takes two void ⚹ arguments and returns a pointer to an int.
    2. declares mist as a pointer to a function that has two void ⚹ arguments and returns an int.
    3. declares mist as a function that takes two void ⚹ arguments and returns an int.
    4. there is a syntax error in the declaration.
    5. Not sure.
  21. What does the following program print? #include < stdio. h > void main (void) {int mat [5] [5] i, j; int ⚹ p; p = & mat [0] [0] for (i = 0; i < 5; i ++) for (j = 0; j < 5; j ++) mat [i] [j] = i + j; printf ( “% d⧵t” sizeof (mat) ) ; < BR > i = 4; j = 5; printf ( “% d” ⚹ (p + i + j) ) ;}
    1. 25 9
    2. 25 5
    3. 50 9
    4. 50 5
    5. Not sure
  22. What is the output of the following program? #include < stdio. h > void main (void) {short x = 0 × 3333; short y = 0 × 4321; long z = x; z = z ≪ 16; z = z|y; printf ( “% 1x⧵t” z) ; z = y; z = z ≫ 16; z = z|x; printf ( “% 1x⧵t” z) ; z = x; y = x && y; z = y; printf ( “% 1x⧵t” z) ;}
    1. 43213333 3333 1
    2. 33334321 4321 4321
    3. 33334321 3333 1
    4. 43213333 4321 4321
    5. Not sure
  23. What is the output of the following program? #include < stdio. h > void main (void) {char ⚹ p = “Bangalore” #if 0 printf ( “% s” p) ; #endif}
    1. syntax error #if cannot be used inside main function
    2. prints Bangalore on the screen
    3. does not print anything on the screen
    4. program gives an error “undefined symbol if”
    5. Not sure
  24. If x is declared as an integer, y is declared as float, consider the following expression: y =⚹ (float ⚹) &x
  25. What is the return type of calloc function?