0% found this document useful (0 votes)
90 views7 pages

Statements: Week: 3 Duration: 60 Mins

The document contains 29 multiple choice questions related to C programming. The questions cover topics like operators, loops, arrays, switch statements, conditional statements, and type casting. For each question, 4 possible answers are provided to choose from.

Uploaded by

subash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views7 pages

Statements: Week: 3 Duration: 60 Mins

The document contains 29 multiple choice questions related to C programming. The questions cover topics like operators, loops, arrays, switch statements, conditional statements, and type casting. For each question, 4 possible answers are provided to choose from.

Uploaded by

subash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

‘C’ & ‘C’ only Sona Placement & Training Cell

3. Statements
Week : 3 Duration : 60 mins

1. Output of the code will be:


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

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

3. Find the Output of the code:


int i,j;
for(i=0;i<=10;i++)
{ j+=5;
assert(i<5); }

4. Predict the Output of the program:


main()
{ int y;
scanf(“%d”,&y); // input given is 2000
if( (y%4==0 && y%100 != 0) || y%100 == 0 )
printf(“%d is a leap year”);
else
printf(“%d is not a leap year”); }

17
‘C’ & ‘C’ only Sona Placement & Training Cell

5. What is the Output of the code?


main()
{ int i=0;
for(;i++;printf(“%d”,i)) ;
printf(“%d”,i);
}

6. Predict the Output of the code:


void main()
{ int i;
char a[]=”\0”;
if(printf(“%s\n”,a))
printf(“Ok here \n”);
else
printf(“Forget it\n”);
}

7. What is the Output of the given program?


void main()
{
while(1) {
if(printf(“%d”,printf(“%d”)))
break;
else
continue; }
}

8. What is the Output of the code:


main()
{ unsigned int i=10;
while(i-->=0)
printf(“%u “,i); }

9. Find the Output of the code:


#include<conio.h>
main()
{ int x,y=2,z,a;
if(x=y%2) z=2;
a=2;
printf(“%d %d “,z,x);
}

18
‘C’ & ‘C’ only Sona Placement & Training Cell

10.What is the Output of the code?


main()
{ unsigned int i=65000;
while(i++!=0);
printf(“%d”,i);
}

11. Predict the Output of the following code:


main()
{ int i=0;
while(+(+i--)!=0)
i-=i++;
printf(“%d”,i);
}

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


main()
{
signed char i=0;
for(;i>=0;i++) ;
printf(“%d\n”,i);
}

13. What is the Output of the code?


main()
{ unsigned char i=0;
for(;i>=0;i++) ;
printf(“%d\n”,i);
}

14. Find the Output of the code:


main()
{ char i=0;
for(;i>=0;i++) ;
printf(“%d\n”,i); }

15. What is the Output of the code:


void main()
{
if(~0 == (unsigned int)-1)
printf(“You can answer this if you know how values
are represented in memory”); }

19
‘C’ & ‘C’ only Sona Placement & Training Cell

16. What is the Output of the code?


main()
{ int i = 3;
for (;i++=0;) printf(“%d”,i); }

17. Find the Output of the code:


void main()
{ static int i;
while(i<=10)
(i>2)?i++:i--;
printf(“%d”, i); }

18. What is the Output of the code given below:


main()
{ float i=1.5;
switch(i)
{ case 1: printf(“1”);
case 2: printf(“2”);
default : printf(“0”); }
}

19. What is the Output of the code given below:


main()
{ int i=3;
switch(i)
{ default:printf(“zero”);
case 1: printf(“one”);
break;
case 2:printf(“two”);
break;
case 3: printf(“three”);
break; } }

20. What is the Output of the code given below:


#include<stdio.h>
main()
{ int i=1,j=2;
switch(i)
{ case 1: printf(“GOOD”);
break;
case j: printf(“BAD”);
break; }
}

20
‘C’ & ‘C’ only Sona Placement & Training Cell

21. What does the following do: for(;;) ;


a) Illegal b)Loops forever c) Ignored by compiler…not illegal

22. Look at the Code:


main()
{ int a[]={1,2,3},i;
for(i=0;i<3;i++)
{ printf(“%d”,*a);
a++; }
}
Which Statement is/are True with respect to the above code?
I.Executes Successfully & Prints the contents of the array
II.Gives the Error:Lvalue Required
III.The address of the array should not be changed
IV.None of the Above.
a) Only I b) Only II c) II & III d) IV

23.
int a,b;
1.main()
2.{
3.scanf(“............”,&a,&b);
4.if...........{
5.printf(“Print A”);
6.else
7.Printf(“...........”);
8.endif}
9..........

A.What will come in the 9 dash?


B.What will happen if we replace Print A as Print X?
C.What will come in the 3 dash?
D.What will happen if we interchange 4 and 7?
E.What will come in the 4 dash?

24.In the (generic) code segment below what will be the value of the variable i
at completion ?
i = 0;
j = 0;
for(j=1;j<10;j++)
i=i+1;
a) 0 b) 1 c) 3 d) 9

21
‘C’ & ‘C’ only Sona Placement & Training Cell

25. Switch statement use only


a) char b) int c) both d) all of the above

3. Assignment

26. What is the Output of the code given below:


main()
{ int K,j;
for(k=0;k<10;k++)
{
some codes }
}

27. What is the output of the following program ?


#include <stdio.h>
void main()
{ printf(“\n10!=9 : %5d”,10!=9);
}
a) 1 b) 0 c) Error d) None of these options

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

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

22
‘C’ & ‘C’ only Sona Placement & Training Cell

30. The statement that prints out the character set from A-Z, is
a) for( a = `z`; a < `a`; a = a - 1) printf(“%c”, &a);
b) for( a = `a`; a <= `z`; a = a + 1) printf(“%c”, &a);
c) for( a = `A`; a <= `Z`; a = a + 1) printf(“%c”, a);
d) for( a = `Z`; a <= `A`; a = a + 1) printf(“%c”, a);

31. 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);

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

33. What will be the output of the program?


#include<stdio.h>
void main()
{ while (1)
{ if (printf(“%d”,printf(“%d”)))
break;
else
continue; }
}
a) Compile time error b) Goes into an infinite loop
c) Garbage values d) None of these options

34. The expression x = 4 + 2 % -8 evaluates to


a) -6 b) 6 c) 4 d) None of these options

35. What is the output of the above program....


int b = 0xAA;
b>>4;
printf(“%x”,b)

23

You might also like