You are on page 1of 18

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.

com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

TITLE: Thompson Reuters Sample Programming Placement Paper Level1 (Bolded option is your answer) 1. Can you combine the following two statements into one? char *p; p = (char*) malloc(100); A char p = B char *p = *malloc(100); (char) malloc(100);

D char *p = (char *)(malloc*)(10 0); 2. If the binary eauivalent of 5.375 in normalised form is 0100 0000 1010 1100 0000 0000 0000 0000, what will be the output of the program (on intel machine)? #include<stdio.h> #include<math.h> int main() { float a=5.375; char *p; int i; p = (char*)&a; for(i=0; i<=3; i++) printf("%02x\n", (unsigned char)p[i]); return 0; } A 40 AC 00 00 B 04 CA 00 00 C 00 00 AC 40

C char *p = (char*)malloc(10 0);

D 00 00 CA 04

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

3. Which statement will you add in the following program to work it correctly? #include<stdio.h> int main() { printf("%f\n", log(36.0)); return 0; } A B C D #include<conio. #include<math. #include<stdlib.h #include<dos.h h> h> > > 4. Which of the following range is a valid long double (Turbo C in 16 bit DOS OS) ? A 3.4E-4932 to 1.1E+4932 B 3.4E-4932 to 3.4E+4932 C 1.1E-4932 to 1.1E+4932 D 1.7E-4932 to 1.7E+4932

5. We want to round off x, a float, to an int value, The correct way to do is A y = (int)(x + 0.5) Dy= (int)((int)x + 0.5) 6. How will you free the memory allocated by the following program? #include<stdio.h> #include<stdlib.h> #define MAXROW 3 #define MAXCOL 4 int main() {
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

B y = int(x + 0.5) C y = (int)x + 0.5

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

int **p, i, j; p = (int **) malloc(MAXROW * sizeof(int*)); return 0; } A memfree(int p); B dealloc(p); C malloc(p, 0); D free(p);

7. What will be the output of the program? #include<stdio.h> #include<math.h> int main() { float i = 2.5; printf("%f, %d", floor(i), ceil(i)); return 0; } A 2, 3 B 2.000000, 3

C 2.000000, 0

D 2, 0

8. What will be the output of the program? #include<stdio.h> int main() { int i; i = scanf("%d %d", &i, &i); printf("%d\n", i); return 0; }
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

A1

B2

C Garbage value

D Error: cannot assign scanf to variable

9. What will be the output of the program? #include<stdio.h> int main() { int i; char c; for(i=1; i<=5; i++) { scanf("%c", &c); /* given input is 'b' */ ungetc(c, stdout); printf("%c", c); ungetc(c, stdin); } return 0; } A bbbb B bbbbb Cb

D Error in ungetc statement.

10. What will be the output of the program? #include<stdio.h> #include<stdlib.h> int main() {
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

char *i = "55.555"; int result1 = 10; float result2 = 11.111; result1 = result1+atoi(i); result2 = result2+atof(i); printf("%d, %f", result1, result2); return 0; } A 55, 55.555 B 66, 66.666600 C 65, 66.666000 D 55, 55

11. What will be the output of the program? #include<stdio.h> int main() { int i; char c; for(i=1; i<=5; i++) { scanf("%c", &c); /* given input is 'a' */ printf("%c", c); ungetc(c, stdin); } return 0; } A aaaa B aaaaa C Garbage value.

D Error in ungetc statement.

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

12. What will be the output of the program? #include<stdio.h> #include<string.h> int main() { char dest[] = {97, 97, 0}; char src[] = "aaa"; int i; if((i = memcmp(dest, src, 2))==0) printf("Got it"); else printf("Missed"); return 0; } A Missed B Got it C Error in memcmp statement 13. Point out the error in the following program. #include<stdio.h> int main() { fprintf("IndiaBIX"); printf("%.ef", 2.0); return 0; }

D None of above

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

A Error: B Error: in C No error and unknown value fprintf() prints "IndiaBIX" in printf() statement. statement. 14. Point out the error in the following program. #include<stdio.h> int main() { char str[] = "IndiaBIX"; printf("%.#s %2s", str, str); return 0; } A Error: in Array B Error: printf declaration statement

D No error and prints "2.0"

C Error: unspecified character in printf 15. How many times "IndiaBIX" is get printed? #include<stdio.h> int main() { int x; for(x=-1; x<=10; x++) { if(x < 5) continue; else break;

D No error

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

printf("IndiaBIX"); } return 0; } A Infinite times B 11 times C 0 times D 10 times

16. How many times the while loop will get executed if a short int is 2 byte wide? #include<stdio.h> int main() { int j=1; while(j <= 255) { printf("%c %d\n", j, j); j++; } return 0; } A Infinite times B 255 times

C 256 times

D 254 times

17. How many times the program will print "IndiaBIX" ? #include<stdio.h> int main() { printf("IndiaBIX"); main();
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

return 0; } A Infinite times B 32767 times C 65535 times D Till stack overflows

18. What will be the output of the program in 16 bit platform (Turbo C under DOS)? #include<stdio.h> int main() { int fun(); int i; i = fun(); printf("%d\n", i); return 0; } int fun() { _AX = 1990; } A Garbage value B 0 (Zero)

C 1990

D No output

19. What will be the output of the program? #include<stdio.h> void fun(int); typedef int (*pf) (int, int); int proc(pf, int, int);
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

int main() { int a=3; fun(a); return 0; } void fun(int n) { if(n > 0) { fun(--n); printf("%d,", n); fun(--n); } } A 0, 2, 1, 0 B 1, 1, 2, 0

C 0, 1, 0, 2

D 0, 1, 2, 0

20. What will be the output of the program? #include<stdio.h> void fun(int*, int*); int main() { int i=5, j=2; fun(&i, &j); printf("%d, %d", i, j); return 0; } void fun(int *i, int *j) {
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

*i = *i**i; *j = *j**j; } A 5, 2 B 10, 4 C 2, 5 D 25, 4

21. What will be the output of the program? #include<stdio.h> int reverse(int); int main() { int no=5; reverse(no); return 0; } int reverse(int no) { if(no == 0) return 0; else printf("%d,", no); reverse (no--); } A Print 5, 4, 3, 2, B Print 1, 2, 3, 4, C Print 5, 4, 3, 2, 1 5 1, 0 22. What will be the output of the program? #include<stdio.h> int check(int);
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

D Infinite loop

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

int main() { int i=45, c; c = check(i); printf("%d\n", c); return 0; } int check(int ch) { if(ch >= 45) return 100; else return 10; } A 100 B 10

C1

D0

23. What will be the output of the program? #include<stdio.h> int fun(int); int main() { float k=3; fun(k=fun(fun(k))); printf("%f\n", k); return 0; } int fun(int i) { i++;
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

return i; } A 5.000000 B 3.000000 C Garbage value D 4.000000

24. Point out the error in the program #include<stdio.h> int main() { int a=10; void f(); a = f(); printf("%d\n", a); return 0; } void f() { printf("Hi"); } A Error: Not B Error: Doesn't C No error D None of allowed print anything above assignment 25. To print out a and b given below, which of the following printf() statement will you use? #include<stdio.h> float a=3.14; double b=3.14;
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

A printf("%f %lf", a, b);

B printf("%Lf %f", a, b);

C printf("%Lf %Lf", a, b);

D printf("%f %Lf", a, b);

26. What will be the output of the program ? #include<stdio.h> int main() { int k=1; printf("%d == 1 is" "%s\n", k, k==1?"TRUE":"FALSE"); return 0; } A k == 1 is TRUE B 1 == 1 is TRUE C 1 == 1 is FALSE D 1 == 1 is FALSE 27. What will be the output of the program ? #include<stdio.h> int main() { float a=3.15529; printf("%2.1f\n", a); return 0; } A 3.00 B 3.15

C 3.2

D3

28. What will be the output of the program ? #include<stdio.h>


Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

int main() { int a=250; printf("%1d\n", a); return 0; } A 1250 B2

C 50

D 250

29. What will be the output of the program if value 25 given to scanf()? #include<stdio.h> int main() { int i; printf("%d\n", scanf("%d", &i)); return 0; } A 25 B2

C1

D5

30. In the following code, the P2 is Integer Pointer or Integer? typedef int *ptr; ptr p1, p2; A Integer B Integer pointer 31. In the following code what is 'P'? typedef char *charp; const charp P;
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

C Error in declaration

D None of above

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

A P is a constant

B P is a C P is character character type constant 32. What is x in the following program? #include<stdio.h>

D None of above

int main() { typedef char (*(*arrfptr[3])())[10]; arrfptr x; return 0; } A x is a pointer B x is an array of C x is an array of D Error in x three pointer three function declaration pointers 33. What will the SWAP macro in the following program be expanded to on preprocessing? will the code compile? #include<stdio.h> #define SWAP(a, b, c)(c t; t=a, a=b, b=t) int main() { int x=10, y=20; SWAP(x, y, int); printf("%d %d\n", x, y); return 0; } A It compiles B Compiles with C Not compile an warning

D Compiles and print

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

nothing 34. According to ANSI specifications which is the correct way of declaring main when it receives command-line arguments? A int main(int argc, char *argv[]) C int main() { int argc; char *argv; } 35. What will be the output of the program? #include<stdio.h> int main() { int y=128; const int x=y; printf("%d\n", x); return 0; } A 128 B Garbage value C Error 36. What will be the output of the program? #include<stdio.h> int main() { const c = -11; const int d = 34;
Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

B int main(argc, argv) int argc; char *argv;

D None of above

D0

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

printf("%d, %d\n", c, d); return 0; } A Error B -11, 34 C 11, 34 D None of these

Visit www.latestoffcampus.com for placement papers, interview tips & job updates. Toget freeupdates tomail https://groups.google.com/group/latestoffcampusLive updates on Facebook @ https://www.facebook.com/LatestOffCampus

You might also like