C Language quiz questions

C Language interview questions

  • 1.

    The maximum combined length of the command-line arguments including the spaces between adjacent arguments is

    1. 128 characters

    2. 256 characters

    3. 67 characters

    4. It may vary from one operating system to another

    Answer
  • 2.

    While calling the fprintf() function in the format string conversion specifier %s can be used to write a character string in capital letters.

    1. True

    2.  

      False

    Answer
  • 3.

    What will be the output of the program ?

    #include<stdio.h>
    
    int main()
    {
        FILE *ptr;
        char i;
        ptr = fopen("myfile.c", "r");
        while((i=fgetc(ptr))!=NULL)
            printf("%c", i);
        return 0;
    }
    1. Print the contents of file "myfile.c"

    2. Print the contents of file "myfile.c" upto NULL character

    3. Infinite loop

    4. Error in program

    Answer
  • 4.

    Point out the error in the program?

    struct emp
    {
        int ecode;
        struct emp e;
    };
    1. Error: in structure declaration

    2. Linker Error

    3. No Error

    4. None of above

    Answer
  • 5.

    What will be the output of the program ?

    #include<stdio.h>
    
    int main()
    {
        enum status {pass, fail, absent};
        enum status stud1, stud2, stud3;
        stud1 = pass;
        stud2 = absent;
        stud3 = fail;
        printf("%d %d %d\n", stud1, stud2, stud3);
        return 0;
    }
    1. 0, 1, 2

    2. 1, 2, 3

    3. 0, 2, 1

    4. 1, 3, 2

    Answer
  • 6.

    What will be the output of the program ?

    #include<stdio.h>
    
    int main()
    {
        printf(5+"IndiaBIX\n");
        return 0;
    }
    1. Error

    2. IndiaBIX

    3. BIX

    4. None of above

    Answer
  • 7.

    Which of the following is correct way to define the function fun() in the below program?

    #include<stdio.h>
    
    int main()
    {
        int a[3][4];
        fun(a);
        return 0;
    }
    1. void fun(int p[][4])
      {
      }
    2. void fun(int *p[4])
      {
      }
    3. void fun(int *p[][4])
      {
      }
    4. void fun(int *p[3][4])
      {
      }
    Answer
  • 8.

    What will be the output of the program if the array begins 1200 in memory?

    #include<stdio.h>
    
    int main()
    {
        int arr[]={2, 3, 4, 1, 6};
        printf("%u, %u, %u\n", arr, &arr[0], &arr);
        return 0;
    }
    1. 1200, 1202, 1204

    2. 1200, 1200, 1200

    3. 1200, 1204, 1208

    4. 1200, 1202, 1200

    Answer
  • 9.

    What will be the output of the program ?

    #include<stdio.h>
    
    int main()
    {
        int i, a[] = {2, 4, 6, 8, 10};
        change(a, 5);
        for(i=0; i<=4; i++)
            printf("%d, ", a[i]);
        return 0;
    }
    void change(int *b, int n)
    {
        int i;
        for(i=0; i<n; i++)
            *(b+1) = *(b+i)+5;
    }
    1. 7, 9, 11, 13, 15

    2. 2, 15, 6, 8, 10

    3. 2 4 6 8 10

    4. 3, 1, -1, -3, -5

    Answer
  • 10.

    What will be the output of the program?

    #include<stdio.h>
    #include<stdlib.h>
    
    int main()
    {
        int i=0;
        i++;
        if(i<=5)
        {
            printf("IndiaBIX");
            exit(1);
            main();
        }
        return 0;
    }
    1. Prints "IndiaBIX" 5 times

    2. Function main() doesn't calls itself

    3. Infinite loop

    4. Prints "IndiaBIx"

    Answer
  • 11.

    Will the printf() statement print the same values for any values of a?

    #include<stdio.h>
    int main()
    {
        float a;
        scanf("%f", &a);
        printf("%f\n", a+a+a);
        printf("%f\n", 3*a);
        return 0;
    }
    1. Yes

    2. No

    Answer
  • 12.

    Which of the following range is a valid long double (Turbo C in 16 bit DOS OS) ?

    1. 3.4E-4932 to 1.1E+4932

    2. 3.4E-4932 to 3.4E+4932

    3. 1.1E-4932 to 1.1E+4932

    4. 1.7E-4932 to 1.7E+4932

    Answer
  • 13.

    Which of the following is the correct order of evaluation for the below expression?
    z = x + y * z / 4 % 2 - 1

    1. * / % + - =

    2. = * / % + -

    3. / * % - + =

    4. * % / - + =

    Answer
  • 14.

    What will be the output of the program?

    #include<stdio.h>
    int main()
    {
        int x=1, y=1;
        for(; y; printf("%d %d\n", x, y))
        {
            y = x++ <= 5;
        }
        printf("\n");
        return 0;
    }
    1. 2 1
      3 1
      4 1
      5 1
      6 1
      7 0

    2. 2 1
      3 1
      4 1
      5 1
      6 1

    3. 2 1
      3 1
      4 1
      5 1

    4. 2 2
      3 3
      4 4
      5 5

    Answer
  • 15.

    What will be the output of the program 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, 4

    2. 4, 2, 2

    3. 2, 8, 4

    4. 2, 4, 8

    Answer
  • 16.

    What do the following declaration signify?

    int *f();
    1. f is a pointer variable of function type.

    2. f is a function returning pointer to an int.

    3. f is a function pointer.

    4. f is a simple declaration of pointer variable.

    Answer
  • 17.

    Bitwise | can be used to multiply a number by powers of 2.

    1. Yes

    2. No

    Answer
  • 18.

    In Turbo C/C++ under DOS if we want that any wild card characters in the command-line arguments should be appropriately expanded, are we required to make any special provision?

    1. Yes

    2. No

    Answer
  • 19.

    What will be the output of the program (sample.c) given below if it is executed from the command line (Turbo C in DOS)?
    cmd> sample 1 2 3

    /* sample.c */
    #include<stdio.h>
    
    int main(int argc, char *argv[])
    {
        int j;
        j = argv[1] + argv[2] + argv[3];
        printf("%d", j);
        return 0;
    }
    1. 6

    2. sample 6

    3. Error

    4. Garbage value

    Answer
  • 20.

    On executing the below program what will be the contents of 'target.txt' file if the source file contains a line "To err is human"?

    #include<stdio.h>
    
    int main()
    {
        int i, fss;
        char ch, source[20] = "source.txt", target[20]="target.txt", t;
        FILE *fs, *ft;
        fs = fopen(source, "r");
        ft = fopen(target, "w");
        while(1)
        {
            ch=getc(fs);
            if(ch==EOF)
                break;
            else
            {
                fseek(fs, 4L, SEEK_CUR);
                fputc(ch, ft);
            }
        }
        return 0;
    }
    1. r n

    2. Trh

    3. err

    4. None of above

    Answer

© 2017 QuizBucket.org