C Language quiz questions

C Language interview questions

  • 1.

    Point out the error in the program?

    #include<stdio.h>
    int main()
    {
        FILE *fp;
        fp=fopen("trial", "r");
        fseek(fp, "20", SEEK_SET);
        fclose(fp);
        return 0;
    }
    1. Error: unrecognised Keyword SEEK_SET

    2. Error: fseek() long offset value

    3. No error

    4. None of above

    Answer
  • 2.

    If the size of pointer is 4 bytes then What will be the output of the program ?

    #include<stdio.h>
    int main()
    {
        char *str[] = {"Frogs", "Do", "Not", "Die", "They", "Croak!"};
        printf("%d, %d", sizeof(str), strlen(str[0]));
        return 0;
    }
    1. 22, 4

    2. 25, 5

    3. 24, 5

    4. 20, 2

    Answer
  • 3.

    What will be the output of the program ?

    #include<stdio.h>
    int main()
    {
        char str = "IndiaBIX";
        printf("%s\n", str);
        return 0;
    }
    1. Error

    2. IndiaBIX

    3. Base address of str

    4. No output

    Answer
  • 4.

    What will be the output of the program ?

    #include<stdio.h>
    int main()
    {
        char str1[] = "Hello";
        char str2[10];
        char *t, *s;
        s = str1;
        t = str2;
        while(*t=*s)
            *t++ = *s++;
        printf("%s\n", str2);
        return 0;
    }
    1. Hello

    2. HelloHello

    3. ello

    4. No output

    Answer
  • 5.

    Which of the following function sets first n characters of a string to a given character?

    1. strinit()

    2. strnset()

    3. strset()

    4. strcset()

    Answer
  • 6.

    A header file contains macros, structure declaration and function prototypes.

    1. True

    2. False

    Answer
  • 7.

    In a macro call the control is passed to the macro.

    1. True

    2. False

    Answer
  • 8.

    A macro must always be defined in capital letters.

    1. True

    2. False

    Answer
  • 9.

    Is it true that too many recursive calls may result into stack overflow?

    1. Yes

    2. No

    Answer
  • 10.

    What will be the output of the program?

    #include<stdio.h>
    #include<math.h>
    int main()
    {
        printf("%f\n", sqrt(36.0));
        return 0;
    }
    1. 6.0

    2. 6

    3. 6.000000

    4. Error: Prototype sqrt() not found.

    Answer
  • 11.

    Can we use a switch statement to switch on strings?

    1. Yes

    2. No

    Answer
  • 12.

    Which of the following statements are correct about an if-else statements in a C-program?

    1: Every if-else statement can be replaced by an equivalent statements using   ?: operators
    2: Nested if-else statements are allowed.
    3: Multiple statements in an if block are allowed.
    4: Multiple statements in an else block are allowed.
    1. 1 and 2

    2. 2 and 3

    3. 1, 2 and 4

    4. 2, 3, 4

    Answer
  • 13.

    What will be the output of the program?

    #include<stdio.h>
    int main()
    {
        float a = 0.7;
        if(0.7 > a)
            printf("Hi\n");
        else
            printf("Hello\n");
        return 0;
    }
    1. Hi

    2. Hello

    3. Hi Hello

    4. None of above

    Answer
  • 14.

    What will be the output of the program, if a short int is 2 bytes wide?

    #include<stdio.h>
    int main()
    {
        short int i = 0;
        for(i<=5 && i>=-1; ++i; i>0)
            printf("%u,", i);
        return 0;
    }
    1. 1 ... 65535

    2. Expression syntax error

    3. No output

    4. 0, 1, 2, 3, 4, 5

    Answer
  • 15.

    What is the purpose of fflush() function.

    1. flushes all streams and specified streams.

    2. flushes only specified stream.

    3. flushes input/output buffer.

    4. flushes file buffer.

    Answer
  • 16.

    Are the following declarations same?

    char far *far *scr;
    char far far** scr;
    1. Yes

    2. No

    Answer
  • 17.

    We can allocate a 2-Dimensional array dynamically.

    1. True

    2. False

    Answer
  • 18.

    In a function that receives variable number of arguments the fixed arguments passed to the function can be at the end of argument list.

    1. True

    2. False

    Answer
  • 19.

    If malloc() successfully allocates memory it returns the number of bytes it has allocated.

    1. True

    2. False

    Answer
  • 20.

    Which header file should be included to use functions like malloc() and calloc()?

    1. memory.h

    2. stdlib.h

    3. string.h

    4. dos.h

    Answer

© 2017 QuizBucket.org