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.

    In C, what is the correct hierarchy of arithmetic operations?

    1. */ + -

    2. * +- /

    3. / *+ -

    4. + - / *

    Answer
  • 3.

    In the following code, what is 'P'?

       Typedef char *charp;
       
       const charp P;

     

    1. P is a constant

    2. P is a character type

    3. P is a pointer

    4. None of the above

    Answer
  • 4.

    Which standard library function can return a pointer to the last occurrence of a character in a string?

    1. stchar()

    2. strrchr()

    3. strchar() & stchar()

    4. strrchar()

    Answer
  • 5.

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

    What is the output of the following program?

    #include<stdio.h>
    
    main()
    {  
       #undef NULL
       char *s = "Hello";
       
       while(*s != NULL)
       {
          printf("%c", *s++);
       }
    }

     

    1. Hello

    2. Compile error: there is no macro called “undef”

    3. Compile error: improper place of #undef

    4. Compile error: NULL is undeclared.

    Answer
  • 7.

    What is the output of the following program?

    #include<stdio.h>
    
    void f(int a[])
    {  
       int i;
       
       for(i=0; i<3; i++)
          a[i]++;
    }
    main()
    {	
       int i,a[] = {10, 20, 30};
       
       f(a);
       for(i=0; i<3; ++i)
       {
          printf("%d ",a[i]);
       }
    }

     

    1. 10 20 30

    2. 11 21 31

    3. Compile error

    4. Runtime error

    Answer
  • 8.

    Special symbol permitted with in the identifier name.

    1. $

    2. @

    3. _

    4. .

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

    According to ANSI specification, how to declare main () function with command-line arguments?

    1. int main(int argc, char *argv[])

    2. int char main(int argc, *argv)

    3. int main()
      {
         Int char (*argv argc);
      )

       

    4. None of the above

    Answer
  • 12.

    In the given below code, what will be return by the function get ()?

    #include<stdio.h>
    
    int get();
    
    int main()
    
    {
       const int x = get();
       
       printf("%d", x);
       return 0;
    }
       int get()
       {
        return 40;
    }

     

    1. 40

    2. 20

    3. 0

    4. 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 Decimal system you can convert the binary number 1011011111000101 very easily.

    1. Yes

    2. Hexadecimal system

    3. Octal system

    4. Both, Octal & Decimal

    Answer
  • 15.

    How do you specify double constant 3.14 as a long double?

    1. By using LD after 3.14

    2. By using L after 3.14

    3. By using DL after 3.14

    4. By using LF after 3.14

    Answer
  • 16.

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

    A macro can execute faster than a function.

    1. true

    2. false

    Answer
  • 19.

    Which operator is used to continue the definition of macro in the next line?

    1. #

    2. ##

    3. $

    4. \

    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