Thursday, June 17, 2010

C Debugging I

1. main()
{
int a,b;
a=- 3 - - 3;
b= - 3 - - (-3);
printf(“%d %d”,a,b);
}
a) – 6 0 b). 0 -6 c) . 0 6. d). Error

2. main()
{
printf (“%d”,4/3);
printf (“%d”, -4%3);
}
a). 1 1 b). 1 -1 c). 1.0 -1 d). Overflow.

3. main()
{
int i=-4, J,num=10;
J=i % - 3;
J=(J ? 0 : num * num);
printf(“ J =%d”,J);
}
a). J=100 b). J= -1 c). J= 0 d). J=1

4. main()
{
char j=1;
while(j<=255)
{
printf(“%d\n”,j);
j=j++;
}
}
a). Error b). 1 2 3.... 255 c). 255 d). Infinite loop

5. main()
{
int x=3,y,z;
z=y=x;
z=y+=x=-z;
printf(“x=%d y=%d z=%d”, x,y,z);
}
a). x=-3 y=0 z=0 b). x= -3 y=4 z=3 c). x=3 y =3 z= 3

6. main()
{
int x=5;
x++;
printf(“x=%d”,x);
++x;
printf(“x=%d”,++x);
}
a) x=6 x=6 b) x=5 x=6 c)x=6 x=7 d)x=6 x= 8

7. main()
{
int x=3,z;
z=x+++10;
printf (“x=%d z=%d”, x,z);
}
a) x=4 z=13 b)x=3 z=13 c)x=3 z=14 d)x=4 z=14


8. main()
{
int i ;
for (i=-1;i<10;i++)
{
if (i<5)
continue;
else
break;
printf(“Gets printed only”);
}
}
a). Infinite loop b). Gets printed only c). -1 2 3 4 5 d). No output

9. main()
{
int i =2;
printf(“i - - = %d”, i--);
}
a). i=1 b). i--=1 c). i--=2 d). Error

10. main()
{
int x=10, y=8;
x=x+y;
y=x-y;
x=x-y;
printf(“x=%d y=%d”,x,y);
}
a). x=10 y=8 b). x=8 y=10 c). x=18 y=10 d). x=10 y=2

12 comments:

  1. nice one. Great Job!!
    Sameer

    ReplyDelete
  2. C debugging is good!!! Keep it up.....

    ReplyDelete
  3. Interesting..enjoyed

    ReplyDelete
  4. C debugging is interesting!!!!!! nice!!!!!

    ReplyDelete
  5. Keep learning C and enjoy debugging it!!!

    ReplyDelete
  6. nice Job....polished our Basics..yeepe yoo..

    ReplyDelete
  7. C Debugging is really good....nice job...!!!

    ReplyDelete
  8. Nice interesting dimag ki bati jalao

    ReplyDelete
  9. Its a good idea.Helps exercise the thinking ability!!!!!

    ReplyDelete
  10. The questions were good, it really make us think

    ReplyDelete
  11. Experiencing new things is great and we are lucky to experience the new world of C, we really enjoyed debugging a C program. Thank You.

    ReplyDelete