C Output Questions

  1. Find Error/Output in follwing code:
  2.                             
    int main ()
    
    {
      int check = 2;
      switch (check)
        {
        case 1:
          printf ("D.W.Steyn");
        case 2:
          printf (" M.G.Johnson");
        case 3:
          printf (" Mohammad Asif");
        default:
          printf (" M.Muralidaran");
        }
      return 0;
    }
    1. D.W.Steyn
    2. D.W.Steyn M.G.Johnson
    3. M.G.Johnson
    4. M.G.Johnson Mohammad Asif M.Muralidaran
Answer :
D
Explanation:
Added By : Abhilasha

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


  1. Find Error/Output in follwing code:
  2.                             
    int main() {
    
      int m = -10, n = 20;
      n = (m < 0) ? 0 : 1;
      printf("%d %d", m, n);
    }
    1. -10 0
    2. 10 20
    3. 20 -10
    4. 0 1
Answer :
A
Explanation:
Added By : Vijay

  1. Find Error/Output in follwing code:
  2.                             
    int main() {
    
      int i=0;
      for(;;) 
        printf("%d",i); 
      return 0;

    1. 0 times
    2. Infinite times
    3. 10 times
    4. 1 times
Answer :
B
Explanation:
Added By : Pankaj

  1. Find Error/Output in follwing code:
  2.                             
    int main() {
    
      char c = 'f';
      switch (c) {
        default: printf("unknown colour ");
        case 'r': case 'R': printf("Red ");
        case 'g': case 'G': printf("Green "); break;
        case 'b': case 'B': printf("Blue");
      }
    }
    1. Red Green Blue
    2. Error
    3. Green unknown colour Red
    4. unknown colour Red Green
Answer :
D
Explanation:
Added By : Abhishek

  1. Find Error/Output in follwing code:
  2.                             
    int main() {
    
      int a = 100, b = 74;
      if (a++ > 100 && b++ > 200)
        printf("High values with a = %d b = %dn", a, b);
      if (a++ < 100 || b++ < 200)
        printf("Low values with a = %d b = %dn", a, b);
     }
    1. Low values with a = 100 b = 74
    2. Low values with a = 101 b = 73
    3. Low values with a = 102 b = 75
    4. Low values with a = 104 b = 75
Answer :
C
Explanation:
Added By : Jayesh


  1. Find Error/Output in follwing code:
  2.                             
    int main() {
    
      char p[] = "%dn";
      p[1] = 'c';
      printf(p, 65);
      int k=40, *a;
      a = &k;
      (*a)++; k++;
      printf("n k=%d",k); 
    }
    1. c k=40
    2. b k=44
    3. A k=42
    4. a k=40
Answer :
C
Explanation:
Added By : Tarun

  1. Find Error/Output in follwing code:
  2.                             
    int main() {
    
      int x = 1;
      while(x = 0)
        printf("hello"); 
    }
    1. hello
    2. No output
    3. Infinite time hello display
    4. Error in code
Answer :
B
Explanation:
Added By : Nikita

Post Your Question
Social Sharing
Search