Online Test for C

  1. The maximum value that an integer constant can have varies from one compiler to another.
    True
    False

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


  1. The return type of malloc function is void.
    True
    False

  1. Which of the following is NOT a valid Real Constant?
    +345.23
    45 22.22
    0.000564
    -3.2

  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));
    }
    6, 10, 8
    4, 8, 4
    2, 4, 4
    2, 8, 8

  1. How to make an infinity loop in C?
    loop: ..... goto loop;
    for(;;) { }
    while(1) { }
    All of the above


  1. The largest element of an array index is called its
    Lower bound
    Upper bound
    Range
    All of the above

  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;
    }
    Infinite Time
    11 Times
    0 Time
    10 Times

  1. Which of the following is allowed in a C Arithmetic instruction
    []
    {}
    ()
    None of the above

  1. Find Error/Output in follwing code:
  2.                                 
    void fn() {
    
     int a = 10;
     static int b = 20;
     printf("a = %d b = %d", ++a, ++b);

    int main() {
     fn();
     fn();
     return 0;
    }
    a = 11 b = 21 a = 11 b = 22
    a = 11 b = 21 a = 11 b = 22
    a = 11 b = 21 a = 11 b = 22
    a = 11 b = 21 a = 11 b = 22

Post Your Question
Social Sharing
Search