C Language quiz questions

C Language interview questions

  • 1.

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

    To print a float value which format specifier can be used?

    1. %f

    2. %lf

    3. %Lf

    4. None of the above

    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.

    The equivalent pointer expression by using the array element a[i][j][k][2],

    1. ((((a+m)+n)+o)+p)

    2. *(*(*(*(a+i)+j)+k)+2)

    3. *( (((a+m)+n)+o+p)

    4. *( ((a+m)+n+o+p)

    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>
    
    main()
    { 
       struct student
       { 
           int num = 10;
       }var;
    
       printf("%d", var.num);
    }

     

    1. 10

    2. Garbage

    3. Runtime error

    4. Compile error

    Answer
  • 7.

    Choose the invalid predefined macro as per ANSI C.

    1. __FILE__

    2. __DATE__

    3. __TIME__

    4. __C++__

    Answer
  • 8.

    What is the output of the following program?

    #include<stdio.h>
    
    main()
    {
       int i = 1;
       
       Charminar:
       printf("%d ",i++);
       if(i==3) break;
       if(i<=5) goto Charminar;
    }

     

    1. 1 2

    2. 1 2 3

    3. 1 2 4 5

    4. Compile error

    Answer
  • 9.

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

    What is the output of the below code snippet?

    #include<stdio.h>
    
    main() 
    {
       for(1;2;3)
          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 “arr” indicate?

    char *arr[30];

     

    1. arr is a array of function

    2. arr is a array of 30 characters

    3. arr is a pointer to an array

    4. arr is a array of 30 character pointers

    Answer
  • 12.

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

    1. 0

    2. 2

    3. 1

    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.

    Which of the following is a logical operator?

    1. !

    2. &&

    3. ||

    4. All of the above

    Answer
  • 15.

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

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

    Does both the loops in the following programs prints the correct string length?

    #include<stdio.h>
    
    main()
    {
       int i;
       char s[] = "hello";
    
       for(i=0; s[i]; ++i);
          printf("%d ", i);
    
       i=0; 
       while(s[i++]);
          printf("%d ", i);
    }
    1. Yes, both the loops prints the correct length

    2. Only for loop prints the correct length

    3. Only while loop prints the correct length

    4. Compile error in the program.

    Answer
  • 18.

    What is the output of the following program?

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

     

    1. 0

    2. 1

    3. 2

    4. Compile error.

    Answer
  • 19.

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

    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

© 2017 QuizBucket.org