• ( 1 ) What will be the output of the following program?
      #include< stdio.h>
      Void f(static int*, extern int);
      Static int b = 12;
      Int main()
      {
      Static int a[5];
      Register int I;
      For(I = 0; I < 2; I ++);
      A[i++] = 2 * i++;
      F(a, b);
      For(I = 0; I < 2; I ++)
      Printf("%d", b++);
      Return 0;
      }
      Void f (static int *x, extern int y)
      {
      Register int I;
      For(I = 0; I < 2; I ++)
      *(++x +1) + = 2;
      Y + = 2;
      }

    • 1) 0 0
    • 2) 0 6
    • 3) 0 12
    • 4) 12 12
    • Discussion in forum
      Answer : 3) 0 12
      Solution :








      discussion


      Answer : 3) 0 12

    • ( 2 ) What will be the output of the following code?
      static int I = 5;
      main()
      {
      int sum = 0
      do
      {
      sum + = (1/i);
      }while(0 < I - -);
      printf("sum of the series is %d", sum);
      }

    • 1) It will print the sum of the series 1/5+1/4+. . .+1/1.
    • 2) It will produce a compilation error.
    • 3) It will produce a run time error.
    • 4) None of these
    • Discussion in forum
      Answer : 3) It will produce a run time error.
      Solution :








      discussion


      Answer : 3) It will produce a run time error.

    • ( 3 ) Regarding the scope of the variables identify the incorrect statement:

    • 1) Automatic variables are automatically initialized to 0
    • 2) Static variables are automatically initialized to 0
    • 3) The address of a register variable is not accessible
    • 4) Static variables cannot be initialized with any expression
    • Discussion in forum
      Answer : 1) Automatic variables are automatically initialized to 0
      Solution : By default Automatic variables are initialized to Garbage value.








      discussion


      Answer : 1) Automatic variables are automatically initialized to 0

    • ( 5 ) What is the output of the following program?
      #include
      static float x=1.2;
      void main()
      {
      printf("%f ",x);
      printf("%d ",y);
      my_func();
      }
      static int y=5;
      int my_func()
      {
      printf("%f ",x);
      printf("%d ",y);
      return 0;
      }

    • 1) 1.200000 5 1.200000 5
    • 2) 1.200000 0 1.200000 5
    • 3) 1.200000 0 1.200000 0
    • 4) Compiler Error
    • Discussion in forum
      Answer : 4) Compiler Error
      Solution :








      discussion


      Answer : 4) Compiler Error

    • ( 6 ) What is the output of the following program
      #include
      int main()
      {
      register int a=10;
      int *p;
      p=&a;
      printf("%u",p);
      return 0;
      }

    • 1) Compiler Error
    • 2) 10
    • 3) adress of a
    • 4) None of these
    • Discussion in forum
      Answer : 1) Compiler Error
      Solution : We cannot dereference register variable since it has not any memory address








      discussion


      Answer : 1) Compiler Error

    • ( 7 ) Output?
      #include
      int a, b, c = 0;
      void prtFun (void);
      int main ()
      {
      static int a = 1; /* line 1 */
      prtFun();
      a += 1;
      prtFun();
      printf ( "\n %d %d " , a, b) ;
      }
      void prtFun (void)
      {
      static int a = 2; /* line 2 */
      int b = 1;
      a += ++b;
      printf (" \n %d %d " , a, b);
      }

    • 1) 3 1
      4 1
      4 2
    • 2) 4 2
      6 1
      6 1
    • 3) 4 2
      6 2
      2 0
    • 4) 3 1
      5 2
      5 2
    • Discussion in forum
      Answer : 3) 4 2
      6 2
      2 0
      Solution :








      discussion


      Answer : 3) 4 2
      6 2
      2 0

    • ( 8 ) Memory allocation using malloc() is done in?

    • 1) Static area
    • 2) Stack area
    • 3) Heap area
    • 4) Both 2 & 3
    • Discussion in forum
      Answer : 3) Heap area
      Solution :








      discussion


      Answer : 3) Heap area

    • ( 9 ) Output of following program
      #include
      int fun(int n)
      {
      static int s = 0;
      s = s + n;
      return (s);
      } int main() { int i = 10, x; while (i > 0) { x = fun(i); i--; } printf ("%d ", x); return 0; }

    • 1) 0
    • 2) 100
    • 3) 110
    • 4) 55
    • Discussion in forum
      Answer : 4) 55
      Solution :








      discussion


      Answer : 4) 55

    • ( 10 ) Where will the space be allocated for an automatic storage class variable?

    • 1) In CPU register
    • 2) In memory as well as in CPU register
    • 3) In memory
    • 4) On disk.
    • Discussion in forum
      Answer : 3) In memory
      Solution :








      discussion


      Answer : 3) In memory





Top