C Language quiz questions

C Language interview questions

  • 1.

    what is the output of the following program

    int  change( int  x )  {
     x = 7; 
    }
    main(){ 
    	int x = 5;
    	change(x);
    	printf(“%d”,x);	
    }

     

    1. 5

    2. 7

    3. unknown

    Answer
  • 2.

    To copy a string into another, given:

    char s1[30] = "xyz", s2[20];

     

    1. s2 = s1;

    2. strcpy(s2,s1);

    3. Both wrong

    Answer
  • 3.

    To copy a string into another, given:

    char s1[30] = "xyz", s2[20];

     

    1. s2 = s1;

    2. strcpy(s2,s1);

    3. Both wrong

    Answer
  • 4.
    for(j=63 , i < 95 , i +=3) x += sqrt(j);

     

    1. is correct

    2. has syntax error

    3. causes run-time error

    Answer
  • 5.

    The computer performs computations internally using

    1. Binary number system

    2. Decimal number system

    3. Hexadec. number system

    Answer
  • 6.

    What is the role of variables in programming languages:

    1. Perform standard functions like printing to the screen

    2. Data storage

    3. Both correct

    Answer
  • 7.

    choose the proper function to compute the cubic value of any input integer n:

    1. int cube(void) { return (n * n * n) ; }

    2. int cube(int n) { return (n * n * n) ; }

    3. void cube(int n) { return (n * n * n) ; }

    Answer
  • 8.

    what is the best choice to print the value of variable x where:

    int x = 123;

     

    1. printf("%d",x);

    2. printf("%c",x);

    3. printf("%f",x);

    Answer
  • 9.

    what is the best choice to store the natural number PI = 3.1459

    1. int pi = 3.1459;

    2. char pi = 3.1459;

    3. float pi = 3.1459;

    Answer
  • 10.

    The value of z in the following statement:

    int x = 9 , y = 2 , z = x / y;

     

    1. 4

    2. 4.5

    3. 5

    Answer
  • 11.

     

    To get a statement from the user input in the array

    char s[100] :

    1. gets( s );

    2. scanf( "%s", s );

    3. Both correct

    Answer
  • 12.

    6. main() { extern int i; i=20; printf("%d",i); }

    1.  

      LINKER ERROR

    2. COMPILER ERROR

    3. 20

    4. ADDRESS

    5. NONE

    Answer
  • 13.

    Main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }

    1.  

      Mmm aaaa nnnnn

    2. Mmmmm aaa nnnn

    3.  

      Mmmm aaaa nnnn

    4. Mmm aaa nnn

    5. NONE

    Answer
  • 14.

    Void main() { int const * p=5; printf("%d",++(*p)); }

    1.  

      COMPILER ERROR

    2. 6

    3. ADDRESS VALUE

    4. 5

    5. NONE

    Answer
  • 15.

    Will the program outputs "IndiaBIX.com"?

    #include<stdio.h>
    #include<string.h>
    int main()
    {
        char str1[] = "IndiaBIX.com";
        char str2[20];
        strncpy(str2, str1, 8);
        printf("%s", str2);
        return 0;
    }
    1. Yes

    2. No

    Answer
  • 16.

    We can modify the pointers "source" as well as "target".

    1. True

    2. False

    Answer
  • 17.

    Point out the error in the following program.

    #include<stdio.h>
    void display(int (*ff)());
    int main()
    {
        int show();
        int (*f)();
        f = show;
        display(f);
        return 0;
    }
    void display(int (*ff)())
    {
        (*ff)();
    }
    int show()
    {
        printf("IndiaBIX");
    }
    1. Error: invalid parameter in function display()

    2. Error: invalid function call f=show;

    3. No error and prints "IndiaBIX"

    4. No error and prints nothing.

    Answer
  • 18.

    What will be the output of the program?

    #include<stdio.h>
    int main()
    {
        char huge *near *far *ptr1;
        char near *far *huge *ptr2;
        char far *huge *near *ptr3;
        printf("%d, %d, %d\n", sizeof(**ptr1), sizeof(ptr2), sizeof(*ptr3));
        return 0;
    }
    1. 4, 4, 4

    2. 2, 2, 2

    3. 2, 8, 4

    4. 2, 4, 8

    Answer
  • 19.

    What do the following declaration signify?

    void *cmp();
    1. cmp is a pointer to an void type.

    2. cmp is a void type pointer variable.

    3. cmp is a function that return a void pointer.

    4. cmp function returns nothing.

    Answer
  • 20.

    Point out the correct statement which correctly free the memory pointed to by 's' and 'p' in the following program?

    #include<stdio.h>
    #include<stdlib.h>
    int main()
    {
        struct ex
        {
            int i;
            float j;
            char *s
        };
        struct ex *p;
        p = (struct ex *)malloc(sizeof(struct ex));
        p->s = (char*)malloc(20);
        return 0;
    }
    1. free(p); , free(p->s);

    2. free(p->s); , free(p);

    3. free(p->s);

    4. free(p);

    Answer

© 2017 QuizBucket.org