Online Test for C

  1. Select worng statement for constructing C variable
    A variable name is any combination alphabets, digits or underscores
    First character in variable must be alphabets and underscore
    Any special symbol can be used in variable name
    No commas or blanks are allowed within a variable name

  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); 
    }
    c k=40
    b k=44
    A k=42
    a k=40


  1. Which of the following has compilation error in C?
    int n = 32;
    char ch = 65;
    float f = (float) 3.2;
    None of the above

  1. A zero value is considered to be false and a non-zero value is considered to be true.
    True
    False

  1. Every C Program must have one function called?
    switch()
    main()
    struct()
    for()

  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. Find Error/Output in follwing code:
  2.                                 
    main() {
    
        int a = 10;      
        if ((fork ( ) == 0))      
        a++;      
        printf ("%dn", a ); 
    }
    10 and 11
    10
    11
    11 and 11

  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;
    }
    6 5
    5 6
    4 5
    5 4

  1. Which is the right way to declare constant in C?
    int constant var =10;
    int const var = 10;
    const int var = 10;
    B & C Both

  1. Find Error/Output in follwing code:
  2.                                 
    main() {
    
     int i = 2, *j;
     j = &i;
     printf("%d", i**j*i+*j); 
    Syntax error due to Invalid expression in printf
    Print junk value
    16
    10

Post Your Question
Social Sharing
Search