C Language quiz questions

C Language interview questions

  • 1.

    Can we specify a variable filed width in a scanf() format string?

    1. Yes

    2. No

    Answer
  • 2.

    The '.' operator can be used access structure elements using a structure variable.

    1. True

    2. False

    Answer
  • 3.

    Point out the error in the program?

    #include<stdio.h>
    #include<string.h>
    void modify(struct emp*);
    struct emp
    {
        char name[20];
        int age;
    };
    int main()
    {
        struct emp e = {"Sanjay", 35};
        modify(&e);
        printf("%s %d", e.name, e.age);
        return 0;
    }
    void modify(struct emp *p)
    {
         p ->age=p->age+2;
    }
    1. Error: in structure

    2. Error: in prototype declaration unknown struct emp

    3. No error

    4. None of above

    Answer
  • 4.

    Point out the error in the program?

    #include<stdio.h>
    int main()
    {
        struct a
        {
            float category:5;
            char scheme:4;
        };
        printf("size=%d", sizeof(struct a));
        return 0;
    }
    1. Error: invalid structure member in printf

    2. Error in this float category:5; statement

    3. No error

    4. None of above

    Answer
  • 5.

    What will be the output of the program in Turbo C (under DOS)?

    #include<stdio.h>
    int main()
    {
        struct emp
        {
            char *n;
            int age;
        };
        struct emp e1 = {"Dravid", 23};
        struct emp e2 = e1;
        strupr(e2.n);
        printf("%s\n", e1.n);
        return 0;
    }
    1. Error: Invalid structure assignment

    2. DRAVID

    3. Dravid

    4. No output

    Answer
  • 6.

    What will be the output of the program ?

    #include<stdio.h>
    #include<string.h>
    int main()
    {
        char str[] = "India\0\BIX\0";
        printf("%s\n", str);
        return 0;
    }
    1. BIX

    2. India

    3. India BIX

    4. India\0BIX

    Answer
  • 7.

    Which of the statements is correct about the program?

    #include<stdio.h>
    int main()
    {
        int arr[3][3] = {1, 2, 3, 4};
        printf("%d\n", *(*(*(arr))));
        return 0;
    }
    1. Output: Garbage value

    2. Output: 1

    3. Output: 3

    4. Error: Invalid indirection

    Answer
  • 8.

    What will be the output of the program ?

    #include<stdio.h>
    int main()
    {
        void *vp;
        char ch=74, *cp="JACK";
        int j=65;
        vp=&ch;
        printf("%c", *(char*)vp);
        vp=&j;
        printf("%c", *(int*)vp);
        vp=cp;
        printf("%s", (char*)vp+2);
        return 0;
    }
    1. JCK

    2. J65K

    3. JAK

    4. JACK

    Answer
  • 9.

    What will be the output of the program ?

    #include<stdio.h>
    int main()
    {
        int x=30, *y, *z;
        y=&x; /* Assume address of x is 500 and integer is 4 byte size */
        z=y;
        *y++=*z++;
        x++;
        printf("x=%d, y=%d, z=%d\n", x, y, z);
        return 0;
    }
    1. x=31, y=502, z=502

    2. x=31, y=500, z=500

    3. x=31, y=498, z=498

    4. x=31, y=504, z=504

    Answer
  • 10.

    How many bytes are occupied by near, far and huge pointers (DOS)?

    1. near=2 far=4 huge=4

    2. near=4 far=8 huge=8

    3. near=2 far=4 huge=8

    4. near=4 far=4 huge=8

    Answer
  • 11.

    It is necessary that a header files should have a .h extension?

    1. Yes

    2. No

    Answer
  • 12.

    In a function two return statements should never occur.

    1. Yes

    2. No

    Answer
  • 13.

    What will be the output of the program?

    #include<stdio.h>
    int main()
    {
        int i=-3, j=2, k=0, m;
        m = ++i && ++j && ++k;
        printf("%d, %d, %d, %d\n", i, j, k, m);
        return 0;
    }
    1. -2, 3, 1, 1

    2. 2, 3, 1, 2

    3. 1, 2, 3, 1

    4. 3, 3, 1, 2

    Answer
  • 14.

    The modulus operator cannot be used with a long double.

    1. True

    2. False

    Answer
  • 15.

    What will be the output of the program?

    #include<stdio.h>
    #include<stdlib.h>
    int main()
    {
        char *i = "55.555";
        int result1 = 10;
        float result2 = 11.111;
        result1 = result1+atoi(i);
        result2 = result2+atof(i);
        printf("%d, %f", result1, result2);
        return 0;
    }
    1. 55, 55.555

    2. 66, 66.666600

    3. 65, 66.666000

    4. 55, 55

    Answer
  • 16.

    What will be the output of the program (in Turbo C under DOS)?

    #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, 8

    2. 2, 4, 4

    3. 4, 4, 2

    4. 2, 4, 8

    Answer
  • 17.

    What do the following declaration signify?

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

    2. cmp is a void type pointer function.

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

    4. cmp is a pointer to a function which returns void .

    Answer
  • 18.

    It is necessary to call the macro va_end if va_start is called in the function.

    1. Yes

    2. No

    Answer
  • 19.

    Can I increase the size of dynamically allocated array?

    1. Yes

    2. No

    Answer
  • 20.

    What will be the output of the program?

    #include<stdio.h>
    int fun(int **ptr);
    int main()
    {
        int i=10;
        const int *ptr = &i;
        fun(&ptr);
        return 0;
    }
    int fun(int **ptr)
    {
        int j = 223;
        int *temp = &j;
        printf("Before changing ptr = %5x\n", *ptr);
        const *ptr = temp;
        printf("After changing ptr = %5x\n", *ptr);
        return 0;
    }
    1. Address of i
      Address of j

    2. 10
      223

    3. Error: cannot convert parameter 1 from 'const int **' to 'int **'

    4. Garbage value

    Answer

© 2017 QuizBucket.org