IBM Previous Years Solved Sample Placement Papers
-
Output of the following program is:
main() { int i = 0; for(i = 0; i < 20; i++) { switch(i) case 0: i += 5; case 1: i += 2; case 5: i += 5; default: i += 4; break; } printf("%d,", i); }
(a) 0,5,9,13,17
(b) 5,9,13,17
(c) 12,17,22
(d) 16,21 (Ans)
(e) Syntax error
-
What is the output of the following program:
main() { char c = -64; int i = -32; unsigned int u = -16; if(c > i) { printf("pass1,"); if(c) printf("pass2"); else printf("Fail2"); } else printf("Fail1"); if(i) printf("pass2"); else printf("Fail2"); }
(a) Pass1,Pass2
(b) Pass1,Fail2
(c) Fail1,Pass2 (Ans)
(d) Fail1,Fail2
(e) None of these
-
In the process table entry for the kernel process, the process ID value is:
(a) 0 (Ans)
(b) 1
(c) 2
(d) 255
(e) It does not have a process table entry
-
Which of the following API is used to hide a window?
(a) ShowWindow (Ans)
(b) EnableWindow
(c) MoveWindow
(d) SetWindowPlacement
(e) None of the above
-
What will the following program do?
void main() { int i; char a[] = "String"; char *p = "New String"; char *Temp; Temp = a; a = malloc(strlen(p) + 1); strcpy(a, p); // Line number: 9 p = malloc(strlen(Temp) + 1); strcpy(p, Temp); printf("(%s, %s)", a, p); free(p); free(a); } // Line number 15
(a) Swap contents of p & a and print: (New string, string)
(b) Generate compilation error in line number 8 (Ans)
(c) Generate compilation error in line number 5
(d) Generate compilation error in line number 7
(e) Generate compilation error in line number 1
-
In the following code segment, what will be the result of the function?
Value of x , value of y { unsigned int x = -1; int y; y = ~0; if(x == y) printf("same"); else printf("not same"); }
(a) same, MAXINT, -1 (Ans)
(b) not same, MAXINT, -MAXINT
(c) same, MAXUNIT, -1
(d) same, MAXUNIT, MAXUNIT
(e) not same, MAXINT, MAXUNIT
-
What will be the result of the following program?
char *gxxx() { static char xxx[1024]; return xxx; } main() { char *g = "string"; strcpy(gxxx(), g); g = gxxx(); strcpy(g, "oldstring"); printf("The string is : %s", gxxx()); }
(a) The string is : string
(b) The string is : Oldstring (Ans)
(c) Run time error/Core dump
(d) Syntax error during compilation
(e) None of these