Test 1 Answers
- What would be the value of i and k?
main()
{
int i,j=5,k;
i=2*j/2;
k=2*(j/2);
}
ANS: 5 4
- What is the output of the following program?
main()
{
int i=-1;
printf(“i=%d,-i=%d”,i,-i);
}
ANS: i=-1 -i=1
- What is the output of the following program?
main()
{
int i=10,j=40;
if((j-i)%10)
printf(“True”);
else
printf(“False”);
}
ANS: False
- What is the output of the following program?
main()
{
char ch[]={‘e’,’n’,’d’,’\0’,’p’};
printf(“%s”,ch);
}
ANS: end
- What is the output of the following program?
main()
{
int i;
for(i=1;i<5;i++);
printf(“Hello”);
}
ANS: Hello
- What is the output of the following program?
main()
{
int x,y=2,z,a;
x=(y*=2)+(z=a=y);
printf(“%d”,x);
}
ANS: 8
- What are the values of x,y,z after executing the following statements?
int x=6,y=8,z;
y=x++;
z=++x;
ANS: 8 6 8
- What is the output of the following program?
main()
{
printf("%d",printf("Hello"));
}
ANS: Hello5
- What is the output of the following program?
main()
{
char x=-256;
printf(“%d”,x);
}
ANS: 0
- What is the output of the following program?
main()
{
int i=4,j=20;
if(i=5||j>50)
printf(“Hello”);
else
printf(“Hi”);
}
ANS: Hello