Online Test for C

  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");
      }
    }
    Red Green Blue
    Error
    Green unknown colour Red
    unknown colour Red Green

  1. The keywords cannot be used as variable names.
    True
    False


  1. To represent hierarchical relationship between elements, which data structure is suitable?
    Priority
    Tree
    Dqueue
    All of the above

  1. A real constant in C can be expressed in both Fractional and Exponential forms.
    True
    False

  1. What is an array?
    An array is a collection of variables that are of the dissimilar data type.
    An array is a collection of variables that are of the same data type.
    An array is not a collection of variables that are of the same data type.
    None of the above.


  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. In switch statement, each case instance value must be _______?
    Constant
    Variable
    Special Symbol
    None of the avobe

  1. What is %f, %d, %s and %c?
    Number Specifier
    Format Specifier
    Access Specifier
    None of the above

  1. Find Error/Output in follwing code:
  2.                                 
    void main()
    
    {
      printf("%d", printf("computer science"));
    }
    computer science16
    16computer science
    computer science
    computer science18

Post Your Question
Social Sharing
Search