C Language quiz questions

C Language interview questions

  • 1.

    Which statement can print \n on the screen?

    1. printf("\\n");

    2. printf("n\");

    3. printf("n");

    4. printf('\n');

    Answer
  • 2.

    What do the following statement defines?

    int *ptr[10];

     

    1. ptr is a pointer to an array of 10 integer pointers.

    2. ptr is a array of 10 pointers to integers

    3. ptr is a array of 10 integer pointers

    4. None of the above

    Answer
  • 3.

    What is x in the following program?

    #include<stdio.h>
    
    int main ()
    {
       typedef char (*(*arrfptr[3])())[10];
       arrfptr x
       return 0;
    }

     

    1. x is a character pointer

    2. x is an array of pointer

    3. x is an array of three function pointers

    4. Wrong declaration

    Answer
  • 4.

    Which library function can convert an integer/long to a string?

    1. ltoa()

    2. ultoa()

    3. sprintf()

    4. None of the above

    Answer
  • 5.

    The binary equivalent of 50 is,

    1. 110010

    2. 1010110

    3. 101

    4. 101.011.00.00

    Answer
  • 6.

    What is the output of the following program?

    #include<stdio.h>
    
    #define sqr(i) i*i
    main()
    {
       printf("%d %d", sqr(3), sqr(3+1)); 
    }

     

    1. 9 16

    2. 9 7

    3. Error: macro cannot be defined in lower case.

    4. None of the above.

    Answer
  • 7.

    Choose the correct option in respect to the following program.

    #include<stdio.h>
    
    void f(int const i) 
    {
       i=5;
    }
    main() 
    {
       int x = 10;
       
       f(x);
    }
    • I - Error in the statement ‘void f(int const i)’

    • II - Error in the statement i=5.

    1. Statements I & II are true

    2. Statements I & II are false.

    3. Statement I is true

    4. Statement II is true.

    Answer
  • 8.

    Identify the C compiler of UNIX.

    1. gcc

    2. cc

    3. Borland

    4. vc++

    Answer
  • 9.

    What is the output of the following program?

    #include<stdio.h>
    
    main()
    {  
       float t = 2;
    
       switch(t)
       {
           case 2: printf("Hi");
           default: printf("Hello");
       }
    }

     

    1. Hi

    2. HiHello

    3. Hello

    4. Error

    Answer
  • 10.

    What is the output of the following program?

    #include<stdio.h>
    
    void f() 
    { 
       static int i;
       
       ++i; 
       printf("%d", i); 
    }
    
    main()
    { 
       f(); 
       f(); 
       f(); 
    }

     

    1. 1 1 1

    2. 0 0 0

    3. 3 2 1

    4. 1 2 3

    Answer
  • 11.

    The maximum combined length of the command-line arguments as well as the spaces between adjacent arguments is:

    a) 120 characters.

    b) 56 characters.

    c) Vary from one OS to another.

    1. a

    2. a, b

    3. a, b, c

    4. c

    Answer
  • 12.

    What will be the output of the following program?

    #include<stdio.h>
    
    int main()
    {
       const int x = 5;
       
       const int *ptrx;
       ptrx = &x;
       *ptrx = 10;
       printf("%d\n", x);
       return 0;
    }

     

    1. 10

    2. 20

    3. 0

    4. The program will return error

    Answer
  • 13.

    How many times the given below program will print "IndiaPIN"?

    #include<stdio.h>
    
    int main ()
    {
       printf("IndiaPIN");
       main();
       return 0;
    
    }

     

    1. Unlimited times

    2. 0 times

    3. 100 times

    4. Till stack run over

    Answer
  • 14.

    In the given below code, if a short int value is 5 byte long, then how many times the while loop will get executed?

    #include<stdio.h>
    
    int main ()
    {
       int j = 1;
       while(j <= 300)
       {
          printf("%c %d\n", j, j);
          j++;
       }
       return 0;
    }

     

    1. Unlimited times

    2. 0 times

    3. 300 times

    4. 5 times

    Answer
  • 15.

    The prototype of a function can be used to,

    1. Define a function

    2. Declare a function

    3. Erase a function

    4. None of the above

    Answer
  • 16.

    What is the output of the following program?

    #include<stdio.h>
    
    int main();
    void main()
    {
       printf("Okay"); 
    }

     

    1. Okay

    2. No output

    3. Compile error. We cannot declare main() function.

    4. Compile error. Mismatch in declaration & definition.

    Answer
  • 17.

    To store a word/sentence declare a variable of the type ‘string’.

    1. true

    2. false

    Answer
  • 18.

    Choose the invalid identifier from the below

    1. Int

    2. volatile

    3. DOUBLE

    4. __0__

    Answer
  • 19.

    What is the following program doing?

    #include<stdio.h>
    
    main()
    {
       FILE *stream=fopen("a.txt",'r');
    }

     

    1. Trying to open “a.txt” in read mode

    2. Trying to open “a.txt” in write mode.

    3. “stream” is an invalid identifier

    4. Compile error

    Answer
  • 20.

    What is the output of the following code snippet?

    #include<stdio.h>
    
    main() 
    {
       short unsigned int i = 0; 
       
       printf("%u\n", i--);
    }

     

    1. 0

    2. Compile error

    3. 65535

    4. 32767

    Answer

© 2017 QuizBucket.org