• ( 1 ) Consider the following program fragment, and choose the correct one
      void main()
      {
      int a, b = 2, c;
      a = 2 * (b++);
      c = 2 * (++b);
      }

    • 1) a = 4, c = 8
    • 2) a = 3, c = 8
    • 3) b = 3, c = 6
    • 4) a = 4, c = 6
    • Discussion in forum
      Answer : 1) a = 4, c = 8
      Solution :








      discussion


      Answer : 1) a = 4, c = 8

    • ( 3 ) Guess the output ?
      #include
      int main()
      {
      int k, num = 100;
      k = (num > 50 ? (num <= 10 ? 100 : 200): 500);
      printf("%d\n", num);
      return 0;
      }

    • 1) 300
    • 2) 500
    • 3) 200
    • 4) 100
    • Discussion in forum
      Answer : 4) 100
      Solution :








      discussion


      Answer : 4) 100

    • ( 4 ) What will be the output?
      void main()
      {
      int a=10, b=20;
      char x=1, y=0;
      if(a,b,x,y)
      {
      printf("EXAM");
      }
      }

    • 1) XAM is printed
    • 2) exam is printed
    • 3) Compiler Error
    • 4) Nothing is printed
    • Discussion in forum
      Answer : 4) Nothing is printed
      Solution :








      discussion


      Answer : 4) Nothing is printed

    • ( 6 ) The precedence of arithmetic operators is (from highest to lowest)

    • 1) %, *, /, +, -
    • 2) %, +, /, *, -
    • 3) +, -, %, *, /
    • 4) %, +, -, *, /
    • Discussion in forum
      Answer : 1) %, *, /, +, -
      Solution :








      discussion


      Answer : 1) %, *, /, +, -

    • ( 7 ) For initialization a = 2, c = 1 the value of a and c after this code will be c = (c) ? a = 0 : 2;

    • 1) a = 0, c = 0;
    • 2) a = 2, c = 2;
    • 3) a = 2, c = 2;
    • 4) a = 1, c = 2;
    • Discussion in forum
      Answer : 1) a = 0, c = 0;
      Solution :








      discussion


      Answer : 1) a = 0, c = 0;

    • ( 8 ) What is the output of this C code?
      #include
      void main()
      {
      int x = 1, z = 3;
      int y = x << 3;
      printf(" %d\n", y);
      }

    • 1) -2147483648
    • 2) -1
    • 3) Run time error
    • 4) 8
    • Discussion in forum
      Answer : 4) 8
      Solution :








      discussion


      Answer : 4) 8

    • ( 10 ) What is the output of this C code?
      int main()
      {
      int i = 5;
      int l = i / -4;
      int k = i % -4;
      printf("%d %d\n", l, k);
      return 0;
      }

    • 1) Compile time error
    • 2) -1 1
    • 3) 1-Jan
    • 4) Run time error
    • Discussion in forum
      Answer : 2) -1 1
      Solution :








      discussion


      Answer : 2) -1 1





Top