Sie sind auf Seite 1von 20

1. What will be output when you will execute following c code?

#include<stdio.h>
int main(){
printf("%d\t",sizeof(6.5));
printf("%d\t",sizeof(90000));
printf("%d",sizeof('A'));
return 0;
}
Choose all that apply:
(A) 4 2 1
(B) 8 2 1
(C) 4 4 1
(D) 8 4 1
(E) 8 4 2

2. Consider on following declaring of enum.

(i)
(ii)
(iii)
(iv)

enum cricket {Gambhir,Smith,Sehwag}c;


enum cricket {Gambhir,Smith,Sehwag};
enum {Gambhir,Smith=-5,Sehwag}c;
enum c {Gambhir,Smith,Sehwag};

Choose correct one:


(A)

Only (i) is correct declaration

(B) Only (i) and (ii) is correct declaration


(C) Only (i) and (iii) are correct declaration
(D) Only (i),(ii) and are correct declaration
(E) All four are correct declaration
Answ er

3.Which of the following is not modifier of data type in c?


(A) Extern
(B) Interrupt
(C) Huge
(D) Register
(E) All of these are modifiers of data type

4. What will be output when you will execute following c


code?
#include<stdio.h>
int main(){
double num=5.2;
int var=5;
printf("%d\t",sizeof(!num));
printf("%d\t",sizeof(var=15/2));
printf("%d",var);
return 0;
}
Choose all that apply:
(A) 4 2 7
(B) 4 4 5
(C) 2 2 5
(D) 2 4 7
(E) 8 2 7

5. Consider on following declaration:


(i)
short i=10;
(ii) static i=10;
(iii) unsigned i=10;
(iv) const i=10;

Choose correct one:


(A)

Only (iv) is incorrect


Only (ii) and (iv) are incorrect

(C)

Only (ii),(iii) and (iv) are correct

(D)

Only (iii) is correct

(E)

All are correct declaration

6.

(B)

What will be output when you will execute following c code?

#include<stdio.h>
int main(){

int a= sizeof(signed) +sizeof(unsigned);


int b=sizeof(const)+sizeof(volatile);
printf("%d",a+++b);
return 0;
}
Choose all that apply:
(A) 10
(B) 9
(C) 8
(D) Error: Cannot find size of modifiers
(E)

7.

Error: Undefined operator +++

Which of the following is integral data type?

(A) Void
(B) Char
(C) float
(D) double
(E)

8.

None of these

What will be output when you will execute following c code?

#include<stdio.h>
const enum Alpha{
X,
Y=5,
Z
}p=10;
int main(){
enum Alpha a,b;
a= X;
b= Z;
printf("%d",a+b-p);
return 0;

}
Choose all that apply:

(A) -4
(B) -5
(C) 10
(D) 11
(E) Error: Cannot modify constant object

9.

What will be output when you will execute following c code?

#include<stdio.h>
extern enum cricket x;
int main(){
printf("%d",x);
return 0;
}
const enum cricket{
Taylor,
Kallis=17,
Chanderpaul
}x=Taylor|Kallis&Chanderpaul;
Choose all that apply:
(A) 0
(B) 15
(C) 16
(D) 17
(E) Compilation error

10.

What will be output when you will execute following c code?

#include<stdio.h>
enum A{
x,y=5,
enum B{
p=10,q
}varp;
}varx;
int main(){
printf("%d %d",x,varp.q);
return 0;
}

Choose all that apply:


(A) 0 11
(B) 5 10
(C) 4 11
(D) 0 10
(E) Compilation error

11.

What will be output of the following program?

#include<stdio.h>
int main(){
int i=5,j;
j=++i+++i+++i;
printf("%d %d",i,j);
return 0;
}
12.

What will be output of the following program?

#include<stdio.h>
int main(){
int i=1;
i=2+2*i++;
printf("%d",i);
return 0;
}
13.

What will be output of the following program?

#include<stdio.h>
int main(){
int a=2,b=7,c=10;
c=a==b;
printf("%d",c);
return 0;
}
14. What will be output of the following program?
#include<stdio.h>
void main(){
int x;
x=10,20,30;

printf("%d",x);
return 0;
}
15.

What will be output of the following program?

#include<stdio.h>
int main(){
int a=0,b=10;
if(a=0){
printf("true");
}
else{
printf("false");
}
return 0;
}
16.

What will be output of the following program?

#include<stdio.h>
int main(){
int a;
a=015 + 0x71 +5;
printf("%d",a);
return 0;
}
17.

What will be output of the following program?

#include<stdio.h>
int main(){
int x=100,y=20,z=5;
printf("%d %d %d");
return 0;
}
18.

What will be output of the following program?

#include<stdio.h>
int main(){
int a;
a=sizeof(!5.6);
printf("%d",a);
return 0;
}

19.

What will be output of the following program?

#include<stdio.h>
int main(){
float a;
(int)a= 45;
printf("%d,a);
return 0;
}
20.In the following program where is the variable a getting defined and where it is getting
declared?
#include<stdio.h>
int main()
{
extern int a;
printf("%d\n", a);
return 0;
}
int a=20;
A.

extern int a is declaration, int a = 20 is the definition

B.

int a = 20 is declaration, extern int a is the definition

C.

int a = 20 is definition, a is not defined

D.

a is declared, a is not defined

21.What is the output of the program given below ?


#include<stdio.h>
int main()
{
enum status { pass, fail, atkt};
enum status stud1, stud2, stud3;
stud1 = pass;
stud2 = atkt;
stud3 = fail;
printf("%d, %d, %d\n", stud1, stud2, stud3);
return 0;
}
A.

0, 1, 2

B.

1, 2, 3

C.

0, 2, 1

22. What

D.

1, 3, 2

is the output of the program

#include<stdio.h>
int main()
{
struct emp
{
char name[20];
int age;
float sal;
};
struct emp e = {"Tiger"};
printf("%d, %f\n", e.age, e.sal);
return 0;
}
A.

0, 0.000000

B.

Garbage values

C.

Error

D.

None of above

23. What will be the output of the program?


#include<stdio.h>
int X=40;
int main()
{
int X=20;
printf("%d\n", X);
return 0;
}
A.

20

B.

40

C.

Error

D.

No Output

24. What is the output of the program


#include<stdio.h>
int main()
{
int x = 10, y = 20, z = 5, i;
i = x < y < z;
printf("%d\n", i);
return 0;
}

A.

B.

C.

Error

D.

None of these

25. What is the output of the program


#include<stdio.h>
int main()
{
int a[5] = {2, 3};
printf("%d, %d, %d\n", a[2], a[3], a[4]);
return 0;
}
A.

Garbage Values

B.

2, 3, 3

C.

3, 2, 2

D.

0, 0, 0

26. What will be the output of the program?


#include<stdio.h>
int main()
{
int X=40;
{
int X=20;
printf("%d ", X);
}
printf("%d\n", X);
return 0;
}
A.

40 40

B.

20 40

C.

20

D.

Error

27. What

will you do to treat the constant 3.14 as a long double?

A.

use 3.14LD

B.

use 3.14L

C.

use 3.14DL

D.

use 3.14LF

28. Which of the following statement obtains the remainder on dividing 5.5 by 1.3 ?
A.

rem = (5.5 % 1.3)

B.

rem = modf(5.5, 1.3)

C.

rem = fmod(5.5, 1.3)

D.

Error: we can't divide

29. 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;
printf("IndiaBIX");
}
return 0;
}
A.

Infinite times

B.

11 times

C.

0 times

D.

10 times

30. 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

31. Which of the following is not logical operator?


A.

&

B.

&&

C.

||

D.

32. Which of the following is the correct order of evaluation for the below expression?
z = x + y * z / 4 % 2 1
A.

/+*-

B.

*-/+

C.

+-/*

D.

/*+-

33. Which of the following are unary operators in C?


1. !
2. Sizeof
3. ~
4. &&

34. In C, if you pass an array as an argument to a function, what actually gets passed?
A.

Value of elements in array

B.

First element of the array

C.

Base address of the array

D.

Address of the last element of array

35. What will be the output of the program ?


#include<stdio.h>
int main()
{
int i=3, *j, k;
j = &i;
printf("%d\n", i**j*i+*j);
return 0;
}
A.

30

B.

27

C.

D.

36. What will be the output of the program ?


#include<stdio.h>
int main()
{

int x=30, *y, *z;


y=&x; /* Assume address of x is 500 and integer is 4 byte size */
z=y;
*y++=*z++;
x++;
printf("x=%d, y=%d, z=%d\n", x, y, z);
return 0;
}
A.

x=31, y=502, z=502

B.

x=31, y=500, z=500

C.

x=31, y=498, z=498

D.

x=31, y=504, z=504

37. What will be the output of the program If the integer is 4bytes long?
#include<stdio.h>
int main()
{
int ***r, **q, *p, i=8;
p = &i;
q = &p;
r = &q;
printf("%d, %d, %d\n", *p, **q, ***r);
return 0;
}
A.

8, 8, 8

B.

4000, 4002, 4004

C.

4000, 4004, 4008

D.

4000, 4008, 4016

38. What will be the output of the program ?


#include<stdio.h>
int main()
{
enum days {MON=-1, TUE, WED=6, THU, FRI, SAT};
printf("%d, %d, %d, %d, %d, %d\n", MON, TUE, WED, THU, FRI, SAT);
return 0;
}
A.

-1, 0, 1, 2, 3, 4

B.

-1, 2, 6, 3, 4, 5

C.

-1, 0, 6, 2, 3, 4

D.

-1, 0, 6, 7, 8, 9

39.

What will be the output of the program ?


#include<stdio.h>
struct course
{
int courseno;
char coursename[25];

};
int main()
{
struct course c[] = { {102, "Java"},
{103, "PHP"},
{104, "DotNet"}

};

printf("%d ", c[1].courseno);


printf("%s\n", (*(c+2)).coursename);
return 0;
}
A.

103 DotNet

B.

102 Java

C.

103 PHP

D.

104 DotNet

40.
#include<stdio.h>
void main()
{
char *str="CQUESTIONBANK";
clrscr();
printf(str+9);
getch();
}
What will output when you compile and run the above code?

(a)CQESTIONBANK
(b)CQUESTION
(c)BANK
(d)Compiler error
41. What will be output of following c code?
#include<stdio.h>
extern int x;
int main(){
do{
do{
printf("%o",x);
}
while(!-2);
}
while(0);
return 0;
}
int x=8;

42. What will be output of following c code?


#include<stdio.h>
int main(){
int i=2,j=2;
while(i+1?--i:j++)
printf("%d",i);
return 0;
}
43. What will be output of following c code?
#include<stdio.h>
int main(){
static int i;
for(++i;++i;++i) {
printf("%d ",i);
if(i==4) break;
}
return 0;
}
44. What will be output of following c code?
#include<stdio.h>
int main(){
int i=1;
for(i=0;i=-1;i=1) {
printf("%d ",i);
if(i!=1) break;
}
return 0;
}
45. What will be output of following c code?
#include<stdio.h>
int main(){
for(;;) {
printf("%d ",10);
}
return 0;
}
46. What will be output of following c code?

#include<stdio.h>
int r();
int main(){
for(r();r();r()) {
printf("%d ",r());
}
return 0;
}
int r(){
int static num=7;
return num--;
}
47. what will be the output ?
#include<stdio.h>
int main(){
int i;
for(i=0;i<=5;i++);
printf("%d",i)
return 0;
}
48. What will be output of following c code?
#include<stdio.h>
int main(){
int x=123;
int i={
printf("c" "++")
};
for(x=0;x<=i;x++){
printf("%x ",x);
}
return 0;
}
49.
What will be output of following code?
#define max 10
void main()
{
int i;
i=++max;
clrscr();
printf("%d",i);
getch();

50. What will be output of following code?


#define max 10+2
void main()
{
int i;
i=max*max;
clrscr();
printf("%d",i);
getch();
}

51.What will

be output of following code?

#define A 4-2
#define B 3-1
void main()
{
int ratio=A/B;
printf("%d ",ratio);
getch();
}

52. What will be output of following


#define MAN(x,y) (x)>(y)?(x):(y)
void main()
{
int i=10,j=9,k=0;
k=MAN(i++,++j);
printf("%d %d %d",i,j,k);
getch();
}
53. What will

code?

be output of following code?

#define START main() {


#define PRINT printf("*******");
#define END }
START
PRINT
END

54.What will be output of


#define CUBE(x) (x*x*x)

following code?

#define M 5
#define N M+1
#define PRINT printf("RITESH");
void main()
{
int volume =CUBE(3+2);
clrscr();
printf("%d %d ",volume,N);
PRINT
getch();
}

55. What will be output when you will execute following c code?
#include<stdio.h>
void main(){
int m=5,n=10,q=20;
if(q/n*m)
printf("William Gates");
else
printf(" Warren Buffet");
printf(" Carlos Slim Helu");
}
Choose all that apply:
(A) William Gates
(B)

Warren Buffet Carlos Slim Helu

(C) Run time error


(D) Compilation error
(E) None of the above

56. What will be output when you will execute following c code?
#include<stdio.h>
void main(){
if(!printf("Mukesh Ambani"))
if(printf(" Lakashmi Mittal"));
}

Choose all that apply:

(A) Mukesh Ambani


(B)

Lakashmi Mittal

(C) It will print nothing


(D) Mukesh Ambani Lakashmi Mittal
(E) Compilation error: if statement without body
57. What will be output when you will execute following c code?
#include<stdio.h>
void main(){
if("ABC") printf("Barack Obama\n");
if(-1)
printf("Hu Jintao\n");
if(.92L) printf("Nicolas Sarkozy\n");
if(0)
printf("Ben Bernanke\n");
if('W')
printf("Vladimir Putin\n");
}

Choose all that apply:


(A)
It will print nothing

(B)
Barack Obama
Hu Jintao
Nicolas Sarkozy
Vladimir Putin
(C)
Barack Obama
Hu Jintao
Nicolas Sarkozy
Ben Bernanke
Vladimir Putin
(D)
Hu Jintao
Nicolas Sarkozy
Vladimir Putin
(E)

Compilation error

58. What will output when you compile and run the above code?

#include<stdio.h>
void main()
{
clrscr();
printf("%d",printf("CQUESTIONBANK"));
getch();
}
(a)13CQUESTIONBANK
(b)CQUESTIONBANK13
(c)Garbage CQUESTIONBANK
(d)Compiler error
59. What will be output when you will execute following c code?
#include<stdio.h>
void main(){
int a=10;
if(printf("%d",a>=10)-10)
for(;;)
break;
else;
}
Choose all that apply:

(A) It will print nothing


(B) 0
(C) 1
(D) Compilation error: Misplaced else
(E) Infinite loop

60. What will be output when you will execute following c code?

#include<stdio.h>
void main(){
int a=5,b=10;
if(++a||++b)
printf("%d %d",a,b);
else
printf("John Terry");
}
Choose all that apply:
(A)

5 10

(B)

6 11

(C)

6 10

(D)

5 11

(E)

John Terry

Das könnte Ihnen auch gefallen