Online Test for C

  1. Which of the following is NOT a valid Integer Constant?
    3
    +343
    -765
    10,000

  1. Find Error/Output in follwing code:
  2.                                 
    #include <stdio.h> 
    
    main( ) {
        int i; 
        for ( i=0; i<5; i++ ) {
            int i = 10;
            printf ( " %d", i );      
            i++; 
        } 
        return 0; 
    10 11 12 13 14
    10 10 10 10 10
    0 1 2 3 4
    Compilation error


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

  1. Which of these assignments is invalid?
    short s = 48;
    float f = 4.3;
    double d = 4.3;
    int I = `1`;

  1. C variable cannot start with
    An alphabet
    A number
    A special symbol other than underscore
    both (b) and (c)

  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. What does the following declaration mean? int (*ptr) [10];
    ptr is an array of pointers of 10 integers.
    ptr is a pointer to an array of 10 integers.
    ptr is an array of 10 integers.
    None of the above

  1. What is right way to Initialization array?
    int num[6] = { 2, 4, 12, 5, 45, 5 } ;
    int n{} = { 2, 4, 12, 5, 45, 5 } ;
    int n{6} = { 2, 4, 12 } ;
    int n(6) = { 2, 4, 12, 5, 45, 5 } ;

  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

  1. A file opened for writing already exists its contents would be overwritten.
    True
    False

Post Your Question
Social Sharing
Search