C Output Questions

  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

  1. Find Error/Output in follwing code:
  2.                             
    How many times "Placement Question" will print.
    
    int main() 
    {
      int x;
      for(x=-1; x<=10; x++)
      {
        if(x < 5)
          continue;
        else
          break;
        printf("Placement Question");
      } 
      return 0;
    }
    1. Infinite Time
    2. 11 Times
    3. 0 Time
    4. 10 Times
Answer :
C
Explanation:
Added By : Nikhil

  1. Find Error/Output in follwing code:
  2.                             
    int main()  
    
    {
      printf("%d%d%d", sizeof(3.14f), sizeof(3.14l));
    }
    1. 4160
    2. 844
    3. 3284
    4. None of the above
Answer :
A
Explanation:
Added By : Satyam


  1. Find Error/Output in follwing code:
  2.                             
    int main()
    
    {
      int a = 10, b = 25;
      a = b++ + a++;
      b = ++b + ++a;
      printf("%d %d n", a, b);
    1. 36 64
    2. 35 62
    3. 36 63
    4. 30 28
Answer :
C
Explanation:
Added By : Abhinav

  1. Find Error/Output in follwing code:
  2.                             
    int main()
    
    {
      char arr[7]="Network";
      printf("%s", arr);
      return 0; 
    }
    1. Network
    2. N
    3. Garbage value
    4. Compilation error
Answer :
A
Explanation:
Added By : Shubham

Social Sharing
Search