Thursday 30 June 2011

Can U debug?? just (C) try this...



1.What is the output?
enum colors {BLACK,BLUE,GREEN};
main()
{
  printf("%d..%d..%d",BLACK,BLUE,GREEN);
  return(1);
}

         

A.. 0..1..2                                                                                                                           
 B. 1..2...3
C. Will not compile
2. Predict the output
#define int char
main()
{
            int i=65;
            printf("sizeof(i)=%d",sizeof(i));
}

A. sizeof(i)=1
B. sizeof(i)=65
C sizeof(i)=2

3. Judge the output
#define square(x) x*x
main()
{
int i;
i = 64/square(4);
printf("%d",i);
}

A..4                B.64      

 C.Compilation error

4. Does the following program generate error?
 #include<stdio.h>
#define a 10
main()
{
#define a 50
printf("%d",a);
}
A. Yes               B. No
           
5.What is the output
#define f(g,g2) g##g2
main()
{
          int var12=100;
          printf("%d",f(var,12));
}


A. Compilation error                                                                                                                   B.100                                                                                                                                                    C.12

1 comment:

  1. This site is very useful for us...
    By
    S.Raja Ram BCA.

    ReplyDelete