C Language quiz questions

C Language interview questions

  • 1.

    Choose the function that is most appropriate for reading in a multi-word string?

    1. strnset()

    2. scanf()

    3. strchr()

    4. gets()

    Answer
  • 2.

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

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

    #include<stdio.h>
    
    int main ()
    {
       int x;
       
       for(x=-1; x<=20; x++)int i;
       {
       if(x < 10)
          continue;
       else
          break;
       printf("India");
    }

     

    1. 20 times

    2. Unlimited times

    3. 21 times

    4. 0 times

    Answer
  • 4.

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

    1. memory.h

    2. math.h

    3. stdio.h

    4. dos.h

    Answer
  • 5.

    In Windows & Linux, how many bytes exist for near, far and huge pointers?

    1. Near: 1, far: 4, huge: 7

    2. near: 4, far: 4, huge: 4

    3. near: 0, far: 4, huge: 4

    4. near: 4, far: 5, huge: 6

    Answer
  • 6.

    What is the output of the following statement?

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

    2. -2

    3. 1

    4. -1

    Answer
  • 7.

    What is the output of the following program?

    #include<stdio.h>
    
    main() 
    {
       char *p = NULL;
       
       printf("%c", *p);
    }

     

    1. NULL

    2. 0

    3. Compile error

    4. Runtime error.

    Answer
  • 8.

    Linker generates ___ file.

    1. Object code

    2. Executable code

    3. Assembly code

    4. None of the above.

    Answer
  • 9.

    What is the output of the following program?

    #include<stdio.h>
    
    void swap(int m, int n)
    {
       int x = m;
       
       m = n;
       n = x;
    }
    main()
    {
       int x=5, y=3;
    
       swap(x,y);
       printf("%d %d", x, y);
    }

     

    1. 3 5

    2. 5 3

    3. 5 5

    4. Compile error

    Answer
  • 10.

    What is the output of the below code snippet?

    #include<stdio.h>
    
    main() 
    {
       for(;;)printf("Hello");
    }

     

    1. Infinite loop

    2. Prints “Hello” once.

    3. No output

    4. Compile error

    Answer
  • 11.

    In the given below statement, what does the “pf” indicate?

    int (*pf)();

     

    1. pf is a pointer of a function which return int

    2. pf is a pointer

    3. pf is a function pointer

    4. None of the above

    Answer
  • 12.

    What value strcmp() function returns when two strings are the same?

    1. 0

    2. 2

    3. 1

    4. Error

    Answer
  • 13.

    What actually get pass when you pass an array as a function argument?

    1. First value of elements in array

    2. Base address of the array

    3. All value of element in array

    4. Address of the last element of array

    Answer
  • 14.

    Which of the following is a logical NOT operator?

    1. !

    2. &&

    3. &

    4. All of the above

    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 statement?

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

     

    1. 2

    2. -2

    3. 1

    4. -1

    Answer
  • 17.

    What is the output of the following program?

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

     

    1. Compile error

    2. Runtime error

    3. 5

    4. 10

    Answer
  • 18.

    What is the built in library function to adjust the allocated dynamic memory size.

    1. malloc

    2. calloc

    3. realloc

    4. resize

    Answer
  • 19.

    What is the output of the following program?

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

     

    1. 1

    2. 0

    3. 2

    4. Compile error

    Answer
  • 20.

    What is the output of the following code snippet?

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

     

    1. 5

    2. 6

    3. Runtime error

    4. Compile error

    Answer

© 2017 QuizBucket.org