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.

    Which of the following statement shows the correct implementation of nested conditional operation by finding greatest number out of three numbers?

    1. max = a>b ? a>c?a:c:b>c?b:c

    2. a=b ? c=30;

    3. a>b : c=30 : c=40;

    4. return (a>b)?(a:b) ?a:c:b

    Answer
  • 3.

    Choose the correct statement that is a combination of these two statements,

       Statement 1: char *p;
       
       Statement 2: p = (char*) malloc(100);

     

    1. char p = *malloc(100);

    2. char *p = (char*)malloc(100);

    3. char *p = (char) malloc(100);

    4. None of the above

    Answer
  • 4.

    Which of the following is a logical NOT operator?

    1. !

    2. &&

    3. &

    4. All of the above

    Answer
  • 5.

    A Variable name in C includes which special symbols?

    1. * (asterisk)

    2. # (Hash)

    3. + (Addition)

    4. _ (underscore)

    Answer
  • 6.

    What is the output of the following program?

    #include<stdio.h>
    
    main()
    { 
       int x = 3;
       
       x += 2;
       x =+ 2;
       printf("%d", x); 
    }

     

    1. 2

    2. 5

    3. 7

    4. Compile error

    Answer
  • 7.

    What is the output of the below code snippet.

    #include<stdio.h>
    
    main()
    {
       printf("%d", -11%2);
    }

     

    1. 1

    2. -1

    3. 5.5

    4. -5.5

    Answer
  • 8.

    Following is the invalid inclusion of a file to the current program. Identify it.

    1. #include <file>

    2. #include “file”

    3. #include < file

    4. All of the above are invalid.

    Answer
  • 9.

    What is the output of the following program?

    #include<stdio.h>
    
    main()
    {
       int i = 1;
       
       while( i++<=5 )
          printf("%d ",i++);
    }

     

    1. 1 3 5

    2. 2 4

    3. 2 4 6

    4. 2

    Answer
  • 10.

    What is the output of the following program?

    #include<stdio.h>
    
    main()
    {	
        register int x = 5;
    
        int *p;
        p=&x;
        x++;
        printf("%d",*p);
    }

     

    1. Compile error

    2. 5

    3. 6

    4. Garbage value

    Answer
  • 11.

    Which statement can print \n on the screen?

    1. printf("\\n");

    2. printf("n\");

    3. printf("n");

    4. printf('\n');

    Answer
  • 12.

    Which of the following statement shows the correct implementation of nested conditional operation by finding greatest number out of three numbers?

    1. max = a>b ? a>c?a:c:b>c?b:c

    2. a=b ? c=30;

    3. a>b : c=30 : c=40;

    4. return (a>b)?(a:b) ?a:c:b

    Answer
  • 13.

    The return keyword used to transfer control from a function back to the calling function.

    1. Yes

    2. Switch

    3. go back

    4. goto

    Answer
  • 14.

    Which of the following is a logical operator?

    1. !

    2. &&

    3. ||

    4. All of the above

    Answer
  • 15.

    In the standard library of C programming language, which of the following header file is designed for basic mathematical operations?

    1. math.h

    2. conio.h

    3. dos.h

    4. stdio.h

    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.

    What is the output of the following program?

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

     

    1. 3 2 1 0

    2. 3 2 1

    3. 3 3 3

    4. Compile error

    Answer
  • 18.

    Identify the C compiler of UNIX.

    1. gcc

    2. cc

    3. Borland

    4. vc++

    Answer
  • 19.

    What is the value of ‘y’ for the following code snippet?

    #include<stdio.h>
    
    main()
    {
       int x = 1;
       
       float y = x>>2;
       
       printf( "%f", y );
    }

     

    1. 4

    2. 0.5

    3. 0

    4. 1

    Answer
  • 20.

    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

© 2017 QuizBucket.org