You are on page 1of 22

Dept.

of Industrial Relations and Placements, Communication and soft skills Subject Name:- C Language 1) The Real constants in C can be expressed in which of the following forms a)Fractional form only b)Exponential form only c)ASCII form only d) a & b 2) The program, which translates high-level program into its equivalent machine language program, is called a)Transformer b)Language processor c)Converter d) none of the above

3) Consider the following statements. i)Multiplication associates left to right ii)Division associates left to right iii)Unary Minus associates right to left iv)subtraction associates left to right a)only i and ii are true b)all are false c)all are true d)only iii and iv are true
4) What will be the value of variable a in the following code? unsigned char a; a = 0xFF + 1; printf("%d", a); a)0xFF b)0x100 c)0 d)0*0 5) What is the output of the following program? #include <stdio.h> void main() { printf("\n10!=9 : %5d",10!=9); } a) 10 b) Error c) None of the above 6) What is the output of the following program? #include<stdio.h> void main() { int x=10; (x<0)?(int a =100):(int a =1000); printf(" %d",a); }

a)Error

b)1000

c)100

d)None of these options

7) Which of the following shows the correct hierarchy of arithmetic operations in C (a), **, * or /, + or (b), **, *, /, +, (c), **, /, *, +, (d), / or *, - or + 8) What is the output of the following code? #include<stdio.h> void main() { int a=14; a += 7; a -= 5; a *= 7; printf("\n%d",a); } a)112 b)98 c)89 d)None of these options

9) What is the output of the following code? #include<stdio.h> #define T t void main() { char T = `T`; printf("\n%c\t%c\n",T,t); } a)Error b)T t c)T T d)t t

10) The statement which prints out the values 1 to 10 on separate lines, is a)for( count = 1; count <= 10; count = count + 1) printf("%d\n",count); b)for( count = 1; count < 10; count = count + 1) printf("%d\n",count); c)for( count = 0; count <= 9; count = count + 1) printf("%d ",count); d)for( count = 1; count <> 10; count = count + 1) printf("%d\n",count); 11) What does the term `call-by-reference` refer to? a)Passing a copy of a variable into a function. b)Passing a pointer to a variable into a function. c)Choosing a random value for a variable. d)A function that does not return any values. 12) What is the output of the following code?

#include<stdio.h> void swap(int&, int&);

void main() { int a = 10,b=20; swap (a++,b++); printf("\n%d\t%d\t",a, b); } void swap(int& x, int& y) { x+=2; y+=3; }

a)14, 24

b)11, 21

c)10, 20

d)Error

13) What is the output of the following program code #include<stdio.h> void abc(int a[]) { a++; a[1]=612; } main() { char a[5]; abc(a); printf("%d",a[4]); } a)100 b)612 c)Error d)None of these options

15) What will happen if you assign a value to an element of an array whose subscript exceeds the size of the array? a)The element will be set to 0 b)Nothing, its done all the time c)Other data may be overwritten d)Error message from the compiler

14) which of the following is true about recursive function i). it is also called circular definition ii). it occurs when a function calls another function more than once iii). it occurs when a statement within the function calls the function itself iv). a recursive function cannot have a return statement within it" a) i and iii b) i and ii c) ii and iv d)i, iii and iv

16) What is the output of the following code? #include<stdio.h> void main() { int arr[2][3][2]={{{2,4},{7,8},{3,4},}, {{2,2},{2,3},{3,4}, }}; printf("\n %d",**(*arr+1)+2+7); } a)16 b)7 c)11 d) Error

17) If int s[5] is a one dimensional array of integers, which of the following refers to the third element in the array? a)*( s + 2 ) b)*( s + 3 ) c)s + 3 d)s + 2 18) What is the output of the following code? void main() { int i = 100, j = 200; const int *p=&i; p = &j; printf("%d",*p); } a)100 b)200 c)300 d)None of the above 19) What is the output of the following code? #include<stdio.h> void main() { int arr[] = {10,20,30,40,50}; int *ptr = arr; printf("\n %d\t%d\t",*ptr++,*ptr); } a)10 20 b)10 10 c)20 20 d)20 10 20) Which of these are reasons for using pointers? 1.To manipulate parts of an array 2.To refer to keywords such as for and if 3.To return more than one value from a function 4.To refer to particular programs more conveniently a)1 & 3 b)Only 1 c)Only 3 d)All of the above 21) During initializing a union a)Only one member can be initialised. initialised. C)Initialisation of a union is not possible. b)All the members will be d)None of these options

22) What would be the output of the following program? #include <stdio.h> main() { printf("\n%c", "abcdefgh"[4]); } a)abcdefgh b)d c)e <------ans d)error 23) What is the output of the following code ? void main() { int a=0; int b=0;

++a == 0 || ++b == 11; printf("\n%d,%d",a,b); } a)0, 1 b)1, 1

c)0, 0

d)1, 0

24) What is the output of the following program? #include<stdio.h> void main() { while (1) {if (printf("%d",printf("%d"))) break; else continue; } } The output is a)Compile time error b)Goes into an infinite loop c)Garbage values d)None of these options
25) Which of the following is the correct way of declaring a float pointer: a)float ptr; b)float *ptr; c)*float ptr; d)None of the above 26) What is the output of the code

27)

main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }


What is the output of the code

28)

main() { float me = 1.1; double you = 1.1; if(me==you) printf("I love U"); else printf("I hate U"); } main() {s

What is the output of the code

29)

static int var = 5; printf("%d ",var--); if(var) main(); }

What is the output of the code

main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }
30) What is the output of the code

31)

main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }

What is the output of the code

32)

main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); } main() { int i=3; switch(i) { default:printf("zero"); case 1: printf("one"); break; case 2:printf("two"); break; case 3: printf("three"); break; }

What is the output of the code

33)

What is the output of the code

34)

main() { printf("%x",-1<<4); }

What is the output of the code

35)

main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); } main() { int c=- -2; printf("c=%d",c); }

What is the output of the code

36)

What is the output of the code

37)

#define int char main() { int i=65; printf("sizeof(i)=%d",sizeof(i)); }

What is the output of the code

38)

main() { int i=10; i=!i>14; Printf ("i=%d",i); }

What is the output of the code

39)

#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); }
What is the output of the code

main()

40)

{ struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); } #include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

What is the output of the code

41)

What is the output of the code

42)

main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }


What is the output of the code

43)

main() { char *p="hai friends",*p1; p1=p; while(*p!='\0') ++*p++; printf("%s %s",p,p1); } #define clrscr() 100 main() { clrscr(); printf("%d\n",clrscr()); } void main()

What is the output of the code

44)

What is the output of the code

45)

{ char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }


What is the output of the code

main() { int i=400,j=300; printf("%d..%d"); }


46)

What is the output of the code

main() { char *p; p="Hello"; printf("%c\n",*&*p); } 47) ) What is the output of the code main() { int i=1; while (i<=5) { printf("%d",i); if (i>2) goto here; i++; } } fun() { here: printf("PP"); }
48) What is the output of the code

49)

main() { static char names[5][20]={"pascal","ada","cobol","fortran","perl"}; int i; char *t; t=names[3]; names[3]=names[4]; names[4]=t; for (i=0;i<=4;i++) printf("%s",names[i]); }
What is the output of the code

void main()

50)

{ int i=5; printf("%d",i++ + ++i); } void main() { int i=5; printf("%d",i+++++i); }

What is the output of the code

51)

What is the output of the code

main() { int i; clrscr(); printf("%d", &i)+1; scanf("%d", i)-1; } a. Runtime error. b. Runtime error. Access violation. c. Compile error. Illegal syntax d. None of the above
52) What is the output of the code

main(int argc, char *argv[]) { (main && argc) ? main(argc-1, NULL) : return 0; } a. Runtime error. b. Compile error. Illegal syntax c. Gets into Infinite loop d. None of the above
53) What is the output of the code

main() { int i = 0xff ;

printf("\n%d", i<<2); } a. 4 b. 512 c. 1020 d. 1024

54)

What is the output of the code

#define SQR(x) x * x main() { printf("%d", 225/SQR(15)); } a. 1 b. 225 c. 15 d. none of the above


55) What is the output of the code

union u { struct st { int i : 4; int j : 4; int k : 4; int l; }st; int i; }u; main() { u.i = 100; printf("%d, %d, %d",u.i, u.st.i, u.st.l); }

a. 4, 4, 0 b. 0, 0, 0 c. 100, 4, 0 d. 40, 4, 0
56) What is the output of the code

union u { union u { int i; int j; }a[10]; int b[10]; }u; main() { printf("\n%d", sizeof(u)); printf(" %d", sizeof(u.a)); // printf("%d", sizeof(u.a[4].i)); } a. 4, 4, 4 b. 40, 4, 4 c. 1, 100, 1 d. 40 400 4
57) What is the output of the code

main() { int i, j, *p; i = 25; j = 100; p = &i; // Address of i is assigned to pointer p printf("%f", i/(*p) ); // i is divided by pointer p } a. Runtime error. b. 1.00000 c. Compile error d. 0.00000
58) What is the output of the code

main() { int i, j; scanf("%d %d"+scanf("%d %d", &i, &j)); printf("%d %d", i, j); } a. Runtime error. b. 0, 0 c. Compile error d. the first two values entered by the user
59) What is the output of the code

main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); } a. Runtime error. b. Hello world c. Compile error d. hello world
60) What is the output of the code

main() { char * strA; char * strB = I am OK; memcpy( strA, strB, 6); } a. Runtime error. b. I am OK c. Compile error d. I am O
61)

How will you print % character? a. printf(\%) b. printf(\\%)

c. printf(%%) d. printf(\%%)
62) What is the output of the code

const int perplexed = 2; #define perplexed 3 main() { #ifdef perplexed #undef perplexed #define perplexed 4 #endif printf("%d",perplexed); } a. 0 b. 2 c. 4 d. none of the above
63) What is the output of the code

struct Foo { char *pName; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); strcpy(obj->pName,"Your Name"); printf("%s", obj->pName); } a. Your Name b. compile error c. Name d. Runtime error
64) What is the output of the code

struct Foo

{ char *pName; char *pAddress; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress); } a. Your Name, Your Address b. Your Address, Your Address c. Your Name Your Name d. None of the above
65) What is the output of the code

main() { char *a = "Hello "; char *b = "World"; clrscr(); printf("%s", strcat(a,b)); } a. Hello b. Hello World c. HelloWorld d. None of the above
66) What is the output of the code

main() { char *a = "Hello ";

char *b = "World"; clrscr(); printf("%s", strcpy(a,b)); } a. Hello b. Hello World c. HelloWorld d. None of the above
67) What is the output of the code

void func1(int (*a)[10]) { printf("Ok it works"); } void func2(int a[][10]) { printf("Will this work?"); } main() { int a[10][10]; func1(a); func2(a); } a. Ok it works b. Will this work? c. Ok it worksWill this work? d. None of the above
68) What is the output of the code

main() { printf("%d, %d", sizeof('c'), sizeof(100)); } a. 2, 2 b. 2, 100 c. 4, 100 d. 4, 4


69) What is the output of the code

main() { int i = 100; clrscr(); printf("%d", sizeof(sizeof(i))); } a. 2 b. 100 c. 4 d. none of the above
70) What is the output of the code

main() { int c = 5; printf("%d", main||c); } a. 1 b. 5 c. 0 d. none of the above


71) What is the output of the code

main() { char c; int i = 456; clrscr(); c = i; printf("%d", c); } a. 456 b. -456 c. random number d. none of the above
72) What is the output of the code

void main () { int x = 10; printf ("x = %d, y = %d", x,--x++); }

a. 10, 10 b. 10, 9 c. 10, 11 d. none of the above


73) What is the output of the code

main() { int i =10, j = 20; clrscr(); printf("%d, %d, ", j-- , --i); printf("%d, %d ", j++ , ++i); } a. 20, 10, 20, 10 b. 20, 9, 20, 10 c. 20, 9, 19, 10 d. 19, 9, 20, 10
74) What is the output of the code

main() { int x=5; clrscr(); for(;x==0;x--) { printf("x=%d\n", x--); } } a. 4, 3, 2, 1, 0 b. 1, 2, 3, 4, 5 c. 0, 1, 2, 3, 4 d. none of the above
75) What is the output of the code

main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } }

a. 5, 4, 3, 2,1 b. 4, 3, 2, 1, 0 c. 5, 3, 1 d. none of the above


76) What is the output of the code

main() { { unsigned int bit=256; printf("%d", bit); } { unsigned int bit=512; printf("%d", bit); } } a. 256, 256 b. 512, 512 c. 256, 512 d. Compile error
77) What is the output of the code

main() { int i; clrscr(); for(i=0;i<5;i++) { printf("%d\n", 1L << i); } } a. 5, 4, 3, 2, 1 b. 0, 1, 2, 3, 4 c. 0, 1, 2, 4, 8 d. 1, 2, 4, 8, 16


78) What is the output of the code

main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit = (bit >> (i - (i -1))));

} } a. 512, 256, 128, 64, 32 b. 256, 128, 64, 32, 16 c. 128, 64, 32, 16, 8 d. 64, 32, 16, 8, 4
79) What is the output of the code

main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit >> (i - (i -1))); } } a. 512, 256, 0, 0, 0 b. 256, 256, 0, 0, 0 c. 512, 512, 512, 512, 512 d. 256, 256, 256, 256, 256 80) What is the output of the code main() { if (!(1&&0)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above 81) What is the output of the code main() {

if ((1||0) && (0||1)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above 82) What is the output of the code main() { signed int bit=512, mBit; { mBit = ~bit; bit = bit & ~bit ; printf("%d %d", bit, mBit); } } a. 0, 0 b. 0, 513 c. 512, 0 d. 0, -513

You might also like