Pages

1.which one is a valid name of a variable in C ?
a)do b)ab#c c)_abc d)3abc
Ans: c

2.Which one of the following statement would produce 1 ?
a)7%-3 b)2.0/2 c)-7/3 d)7.0%-3.0
Ans: a

3.What would be the output of the following program ?
main()
{
int i=10;
printf("%d",sizeof(i));
}
Ans: 2

4.Which one is the correct format specifier for long unsigned integer ?
a)%ld b)%u c)%Lu d)%lu
Ans: d

5.What will be the output of the following program?
main()
{
printf("%c",65);
}
Ans: A

6.What’s the result of following expression?
5 + 10 / 3 * ( 8 – 6 )
Ans:11

7.What would be the output of the following program?
main()
{
int x=5,x;
x=y=5;
if(x=5)
printf("Five");
else
printf("Six");
}
Ans:Five Six

8.What would be the output of the following program?
main()
{
int a=2,b=3;
if(a==b);
printf("Dennis");
else
printf("Ritchie");
}
Ans:Dennis Ritchie

9.What would be the output of the following program?
main()
{
int a;
if(a=0)
printf("Zero");
else
printf("Hero");
}
Ans:Hero

10.What would be the output of the following program?
main()
{
int x=6;
if(x==5)
printf("Five");
printf("Six");
else
printf("Seven");
}
Ans:Six Seven

11.
What would be the output of the following program?
main()
{
int x=5;
int z,w;
z=x<6; w="x<3;">printf("z=%d w=%d",z,w);
}
Ans:z=1 w=0


12.
What would be the output of the following program?
main()
{
int a=3,b;
b=a++;
printf("a=%d b=%d",a,b);
}
Ans:a=4 b=3


13.What will be the output of the following programs?
main()
{
int a=5,b,c;
if(a==3)
b=8;
c=b+a;
printf("c=%d",c);
}
Ans:A garbage value.

14.What would be the output of the following program?
main()
{
int x=7,y=5;
x=x+y;
y=x-y;
x=x-y;
printf("x=%dy=%d",x,y);
}
Ans:x=5 y=7

15.What would be the output of the following program?
main()
{
int a=5,b=7,c;
c=a;
a=b;
b=c;
printf("a=%db=%d",a,b);
}
Ans:a=7 b=5


16.What would be the output of the following program?
main()
{
int a=123,b,c,d;
b=123/100;
c=123%10;

d=b+c;
printf("%d",d);
}
Ans:4

17.What would be the output of the following program?
main()
{
int x=2;
printf("%d%d%d",x,x++,++x);
}
Ans:4 4 3

18.
What would be the output of the following program?
main()
{
int x=5;
printf("%d%d%d",x!=7,x=7,x<8); size="3">What would be the output of the following program?
main()
{
int x=35;
char y='#';
if(x==y)
printf("True");
else
printf("False");
}
Ans:True

20.Correct sequence of execution of the following program-
for(exp1,exp2,exp3)
{
Statements;
}
a)exp1,exp2,exp3,statements
b)exp1,exp3,exp2,statements
c)exp1,exp2,statements,exp3
d)exp1,exp3,statements,exp2
Ans:c

21.which of the following statement is true?
a)Testing part is optional in while loop
b)
Testing part is optional in do-while loop
c)
Initialization,testing and incrementation pat of a for loop is optional
d)while(1) this loop will execute only once
Ans:c

22.What will be the output of the following program?
main()
{
int x=4,y=5;
printf("%d",x,y);
}
Ans: 4