Tuesday, October 21, 2014

Do U know?


1.What is the output of this C code?
    #include <stdio.h>
    void main()
    {
        int a = 3;
        int b = ++a + a++ + --a;
        printf("Value of b is %d", b);
    }

a) Value of x is 12, b) Value of x is 13, c) Value of x is 10,  d) Undefined behavior


2. The precedence of arithmetic operators is (from highest to lowest)
a) %, *, /, +, -                         b) %, +, /, *, -
c) +, -, %, *, /                          d) %, +, -, *, /

3. What is the output of this C code?
    #include <stdio.h>
    int main()
    {
        int a = 10;
        double b = 5.6;
        int c;
        c = a + b;
        printf("%d", c);
    }

a) 15                b) 16                c) 15.6             d) 10

4. What is the output of this C code?
    #include <stdio.h>
    int main()
    {
        int a = 10, b = 5, c = 5;
        int d;
        d = a == (b + c);
      printf("%d", d);
    }
a) Syntax error             b) 1                  c) 10                d) 5

5. What is the output of this C code?
   #include <stdio.h>
    main()
    {
        char *p = 0;
        *p = 'a';
        printf("value in pointer p is %c\n", *p);
    }
 
a) It will print a          b) It will print 0            c) Compile time error     d) Run time error


6. What is the output of this C code?
 #include <stdio.h>
   main()
   {
       if (sizeof(int) > -1)
           printf("True");
       else
           printf("False");
   }
 
a) True       b) False

No comments:

Post a Comment