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 will be the output of the following program?

    #include<stdio.h>
    
    int main()
    {
       const int i = 0;
        
       printf("%d\n", i++);
       return 0;
    }

     

    1. 100

    2. Infinity

    3. 0

    4. Return error

    Answer
  • 3.

    Which of the following header file can be used to define the NULL macro?

    1. stdio.h, locale.h, stddef.h, stdlib.h, string.h,

    2. stddef.h, locale.h, math.h, stdlib.h, string.h,

    3. time.h, wchar.h, math.h, locale.h,

    4. math.h

    Answer
  • 4.

    What is a pointer?

    1. A keyword used to create variables

    2. A variable used to store address of an instruction

    3. A variable used to store address of other variable

    4. A variable used to store address of a structure

    Answer
  • 5.

    Which header statement is missing in the given below program to get the desired output?

    #include<stdio.h>
    #include<math.h>
    
    int main ()
    {
       double x = 1234321;
      
       double result = sqrt(x);
      
       printf("The square root of %.2lf is %.2lf\n", x, result);
       return 0;
    }

     

    1. #include<defs.h>

    2. #include<math.h>

    3. #include<stdlib.h>

    4. Above program is absolutely correct to give desired result

    Answer
  • 6.

    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
  • 7.

    What is the output of the following program?

    #include<stdio.h>
    
    main()
    {
       char s[] = "Fine";
       *s = 'N';
       
       printf("%s", s);
    }

     

    1. Fine

    2. Nine

    3. Compile error

    4. Runtime error

    Answer
  • 8.

    Function fopen() with the mode "r+" tries to open the file for __

    1. reading and writing

    2. reading and adding new content

    3. only for reading

    4. it works only for directories

    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 code snippet?

    #include<stdio.h>
    
    main()
    { 
       int *p = 15; 
       printf("%d",*p);
    }

     

    1. 15

    2. Garbage value

    3. Runtime error

    4. Compiler error

    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.

    Choose the correct order of evaluation,

    1. Relational Arithmetic Logical Assignment

    2. Arithmetic Relational Logical Assignment

    3. Logical Arithmetic Relational Assignment

    4. Assignment Arithmetic Logical Relational

    Answer
  • 13.

    Which of the following header file can be used to define the NULL macro?

    1. stdio.h, locale.h, stddef.h, stdlib.h, string.h,

    2. stddef.h, locale.h, math.h, stdlib.h, string.h,

    3. time.h, wchar.h, math.h, locale.h,

    4. math.h

    Answer
  • 14.

    Which header file can be used to define input/output function prototypes and macros?

    1. math.h

    2. memory.h

    3. stdio.h

    4. dos.h

    Answer
  • 15.

    Choose the correct statement that can retrieve the remainder of the division 5.5 by 1.3?

    1. rem = modf(5.5 % 1.3)

    2. rem = modf(5.5, 1.3)

    3. rem = fmod(5.5, 1.3)

    4. rem = f(5.5, 1.3)

    Answer
  • 16.

    What is the output of the following program?

    #include<stdio.h>
    
    main()
    { 
       char s1[50], s2[50] = "Hello";
       
       s1 = s2;
       printf("%s", s1);
    }

     

    1. Hello

    2. No output

    3. Compile error

    4. Runtime error

    Answer
  • 17.

    What is the output of the following program?

    #include<stdio.h>
    
    main()
    {
       char s[] = "Fine";
       *s = 'N';
       
       printf("%s", s);
    }

     

    1. Fine

    2. Nine

    3. Compile error

    4. Runtime error

    Answer
  • 18.

    What is the output of the following program?

    #include<stdio.h>
    
    main()
    { 
       int a[3] = {2,1};
       
       printf("%d", a[a[1]]); 
    }

     

    1. 0

    2. 1

    3. 2

    4. 3

    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 your comment on the below C statement?

    signed int *p=(int*)malloc(sizeof(unsigned int));

     

    1. Improper type casting

    2. Would throw Runtime error

    3. Memory will be allocated but cannot hold an int value in the memory

    4. No issue with statement

    Answer

© 2017 QuizBucket.org