# Placement Papers: Blue Star Placement Paper1 Mar 2010

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.

1. What would be the output of the following program. #include < stdio. h > main () {extern int a; printf ( “% d” a) ;} int a = 20
1. 20
2. 0
3. garbage value
4. error!
2. What would be the output of the following program. Main () {int a  = {2,3} ; printf ( “⧵n % d % d % d” a  a  a  ) ;}
1. garbage value
2. 2 3 3
3. 3 2 2
4. 0 0 0
3. What would be the output of the following program. Main () {inti =-3, j = 2, k = 0, m; m =+ + i&& ++ j |+ + k; printf ( “⧵n % d % d % d % d” i, j, k, m) ;}
1. -2 3 0 1
2. -3 2 0 1
3. -2 3 1 1
4. error
4. What would be the output of the following program. Main () {int a, b; a = sumdig (123) ; b = sumdig (123) ; printf ( “% d % d” a, b) ;} sumdig (int n) {static int s = 0; int d; if (n! = 0) {d = n % 10; n = (n-d) /10; s = s + d; sumdig (n) ;} else return (s) ;}
1. 12 6
2. 6 12
3. 3 15
4. error
5. What would be the output of the following program. #define CUBE (x) (x ⚹ x ⚹ x) main () {int a, b = 3; a = CUBE (b ++) ; printf ( “⧵n % d % d” a, b) ;}
1. 64 4
2. 27 4
3. 27 6
4. 64 6
6. What would be the output of the following program. Main () {const int x = get () ; printf ( “% d” x) ;} get () {return (20) ;}
1. 20
2. garbage value
3. error
4. 0
7. A function has this prototype void f1 (int ⚹⚹ x) , How will you call this function?
1. int ⚹⚹ a
2. int a
3. int ⚹ a
4. int a = 5
8. pointout the error, if any, in the for loop main () {int l = 1; for; {printf ( “% d” l ++) ; if (l > 10) break;} }
1. The condition in the for loop is a must
2. The two semicolons should be dropped
3. The for loop should be replaced by awhile loop
4. No error
9. Can the following piece of code be executed? int main (void) {char strA  = “compile” strB  my_strcpy (strB, strA) ; puts (strB) ;} char ⚹ my_strcpy (char ⚹ destination, char ⚹ source) {char ⚹ p = destination; while (⚹ source! = ‘⧵0’ ) {⚹ p ++ =⚹ source ++ ;} ⚹ p = ‘⧵0’ return destination;}
1. Compilation will only give a warning but will proceed to execute & will display “compile”
2. The compilation error char ⚹ (char ⚹ , char ⚹) differs in levels of indirection from ‘int () ’ will occur
3. Yes & it will print compile on the screen
4. None of the above
10. What would be the output of the following program. #include < stdio. h > main () {char str  = “fast” static char ⚹ ptr_to_array = str; printf ( “% s” ptr_to_array) ;}
1. Compilation will only give a warning but will proceed to execute & will display “fast”
2. display “fast” on screen
3. will give a compilation error
4. none of the above
11. What would be the output of the following program. Main () {int number, ⚹ p; number = 5; p = &number; printf ( “% d” ⚹ p) ;}
1. 6
2. 5
3. junk value
4. compilation error
12. What would be the output of the following program. Main () {int a  = {2,3, 4} ; char ⚹ p; p = a; p = (char ⚹) ( (int ⚹) p + 1) ; printf ( “% d” p) ;}
1. 2
2. 0
3. junk value
4. 3
13. What would be the output of the following program. Main () {int i = 10; fn (i) ; printf ( “% d” i) ;} fn (int i) {return ++ i;}
1. 10
2. 11
3. 12
4. Compilation error
14. What will be the value of i & j after the loop is executed? for (i = 0, j = 0; i < 5, j < 25; i ++ , j ++)
1. i = 4, j = 24
2. i = 24, j = 24
3. i = 25, j = 25
4. i = 5, j = 25
15. What would be the output of the following program. Main () {int i, j; i = 10; j = sizeof (++ i) ; printf ( “% d” i) ;}
1. 11
2. 10
3. 4
4. compilation error
16. What would be the output of the following program. Main () {int i = 7; printf ( “% d⧵n” i ++ ⚹ i ++) ;}
1. 49
2. 56
3. 72
4. compilation error
17. What will the printf print? main () {char ⚹ p, ⚹ f () ; p = f () ; printf ( “f () returns:% s⧵n” p) ;} char ⚹ f () {char result  strcpy (result, “anything will do” ) ; return (result) ;}
1. f () returns: Anything will do
2. f () returns:
3. compilation error
4. The printf statement is not going to be executed
18. How many times the following program would print ‘Jamboree’ main () {printf ( “⧵n Jamboree” ) ; main () ;}
1. infinite number of times
2. 32767 times
3. 65535 times
4. till the stack does not overflow
19. Notice the error in the default statement in the code snippet below. Will it give a compilation error? main () {int a = 10, j; j = fn (a) ; switch (j) {case 30: Printf ( “the value is 30” ) ; break; case 50: Printf ( “the value is 50” ) ; break; default: Printf ( “the value is not 30 or 50” ) ;} } fn (int a) {return (++ a) ;}
1. Will display “the value is 30”
2. Will display “The value is not 30 or 50”
3. Yes a compilation error would happen
4. No compilation errors but there will be no output on the screen
20. What would be the output of the following program. Main () {struct emp {char name  int age; float sal;} ; struct emp e = { “tiger” } ; printf ( “⧵n % d % f” e. Age, e. Sal) ;}
1. 0 0.000000
2. Garbage values
3. Error
4. none of the above

Developed by: