C Output Questions

  1. Find Error/Output in follwing code:
  2.                             
    void main ()
    
    {
      int x = 128;
      printf ("n%d", 1 + x++);
    }
    1. 128
    2. 129
    3. 130
    4. 131
Answer :
B
Explanation:
Added By : Justin

  1. Find Error/Output in follwing code:
  2.                             
    #include <stdio.h> 
    
    int tmp=20; 
    main( ) {    
        printf("%d ",tmp);    
        func( );    
        printf("%d ",tmp); 

    func() {    
        static int tmp=10;    
        printf("%d ",tmp); 
    }
    1. 20 10 10
    2. 20 10 20
    3. 20 20 20
    4. 10 10 10
Answer :
B
Explanation:
Added By : Sunny


  1. Find Error/Output in follwing code:
  2.                             
    main() {
    
        int a = 10;      
        if ((fork ( ) == 0))      
        a++;      
        printf ("%dn", a ); 
    }
    1. 10 and 11
    2. 10
    3. 11
    4. 11 and 11
Answer :
B
Explanation:
Added By : Sandhya

  1. Find Error/Output in follwing code:
  2.                             
    #include <stdio.h> 
    
    main( ) {
        int i; 
        for ( i=0; i<5; i++ ) {
            int i = 10;
            printf ( " %d", i );      
            i++; 
        } 
        return 0; 
    1. 10 11 12 13 14
    2. 10 10 10 10 10
    3. 0 1 2 3 4
    4. Compilation error
Answer :
B
Explanation:
Added By : Himanshu

  1. Find Error/Output in follwing code:
  2.                             
    struct
    
    {
      int si;
      double d;
      float cp;
    } s;
    void
    main ()
    {
      printf ("%d, %d, %d",  sizeof (s.si), sizeof (s.d), sizeof (s.cp));
    }
    1. 6, 10, 8
    2. 4, 8, 4
    3. 2, 4, 4
    4. 2, 8, 8
Answer :
B
Explanation:
Added By : Jatin

  1. Find Error/Output in follwing code:
  2.                             
    int main ()
    
    {
      int a, b;
      a = b = 4;
      b = a++;
      printf ("%d %d %d %d", a++, --b, ++a, b--);
    }
    1. 5 3 7 3
    2. 5 4 5 3
    3. 6 2 6 4
    4. Syntax Error
Answer :
C
Explanation:
Added By : Irfan


  1. Find Error/Output in follwing code:
  2.                             
    int main ()
    
    {
      int a[4] = { 25, 16 };
      printf ("%d %d", a[0] & a[1], a[1] | a[2]);
    }
    1. Syntax error because of invalid operator symbol
    2. 25 16
    3. 16 16
    4. Syntax error because of invalid array initialization
Answer :
C
Explanation:
Added By : Rishab

  1. Find Error/Output in follwing code:
  2.                             
    int main ()
    
    {
      static int num = 8;
      printf ("%d", num = num - 2);
      if (num != 0)
        main ();
    }
    1. 8 6 4 2
    2. Infinite output
    3. Invalid because main function can't call itself.
    4. 6 4 2 0
Answer :
D
Explanation:
Added By : Rohit

Post Your Question
Social Sharing
Search