Genesis Insoft The name you can TRUST
twitterlogo facebooklogo
Home  |  Contact Us |  Careers
C Question Bank / FAQs

This is a mock Exam for the C programmers. It is created by Genesis InSoft Limited (admin@genesisinsoft.com) and may be freely distributed so long as it is unmodified. Please email us if you have any corrections or comments.

Question 1

What is the output of the program?

    #include <stdio.h>
   
    // Assume size of integer as 4 bytes
   
    void main()
    {
        char (*p)[3];
        printf("\n %d %d", sizeof(*p), sizeof(p));
    }

  1. 12 4
  2. 3 4
  3. 1 3
  4. 4 12

Answer to Question 1

Question 2

What is the output of the program?

    #include <stdio.h>

    void main()
    {
        const char* ptr = "Genesis";
        printf(" %c ", (*++ptr)++);
    }

  1. No error, output is e
  2. No error, output is n
  3. No error, output is G
  4. l-value specifies const object

Answer to Question 2

Question 3

The functionality of "ferror(FILE *)" is

  1. ferror is a macro that tests the given stream for a read error only
  2. ferror is a macro that tests the given stream for a file open error
  3. ferror is a macro that tests the given stream for a read or write error
  4. ferror is a macro that tests the given stream for a file close error

Answer to Question 3

Question 4

Which of the following function does not return an integer value?

  1. printf
  2. scanf
  3. strcpy
  4. strlen

Answer to Question 4

Question 5

What is the output of the program?

    #include <stdio.h>
    main()
    {
        static char Arr[8] = "Genesis";
        char* ptr = &Arr[6] - 3;
        printf("\n %s", ptr);
    }

  1. e
  2. sis
  3. esis
  4. n

Answer to Question 5

Question 6

Which of the following functions support dynamic memory allocation?

  1. malloc
  2. realloc
  3. calloc
  4. All the three A, B and C

Answer to Question 6

Question 7

What is the significance of putw() function?

  1. writes only character data to the file in text mode
  2. writes only integer data to the file in binary mode
  3. writes integer data to the file in text mode
  4. writes character data to the file in binary mode

Answer to Question 7

Question 8

What is the output of the program?

    #include <stdio.h>
    main()
    {
        for( ; ; )
            main();
    }

  1. Error: syntax error at or before;
  2. Executes once
  3. It will result in infinite loop until stack overflow occurs
  4. Error: illegal call to function main()

Answer to Question 8

Question 9

What is the output of the program?

    #include <stdio.h>

    // Assume integer is 4 bytes
        
    struct {
        char *p;
        int (*fun)();
    } a;

    void main()
    {
        printf("\n %d %d %d ", sizeof(a), sizeof(a.p), sizeof(a.fun));
    }

  1. 8 4 4
  2. 5 1 4
  3. 6 2 4
  4. Error: pointer to functions is not allowed in structures

Answer to Question 9

Question 10

What is the output of the program?

    #include <stdio.h>

    void main()
    {
        int Var = 90;
        if(Var += Var == ++Var == 89)
            printf(" %d ",Var);
    }

  1. 180
  2. 91
  3. 90
  4. 182

Answer to Question 10

Question 11

Which of the functions always write the output to Video Display Unit?

  1. puts
  2. putc
  3. putch
  4. fputs

Answer to Question 11

Question 12

Which of the declarations cannot be performed above main()?

  1. variables of auto storage class
  2. enum declaration
  3. variables of extern storage class
  4. static union declaration

Answer to Question 12

Question 13

What is the output of the program if the input is 103?

    main()
    {
        int p = 234;
        printf(" %d ", printf("%d", p), scanf("%d", &p));
    }

  1. 3 103
  2. 103
  3. 103 3
  4. 103 2

Answer to Question 13

Question 14

What is the difference between scanf() and gets() while scanning a bunch of characters??

  1. scanf() takes input from stdin, but gets() gets input from console
  2. scanf() put a null at the end of the string, but gets() does not
  3. gets() can scan even the spaces, but scanf() cannot
  4. None of the above

Answer to Question 14

Question 15

Which of the functions compares two strings ignoring the case?

  1. strcmp
  2. strncmp
  3. stricmp
  4. strcpy

Answer to Question 15

Question 16

What is the output of the program?

    int fun(int num)
    {
        return printf(" %d ", num);
    }

    void main()
    {
        printf(" Genesis ", fun(123), " & Genesis");
    }

  1. 123 Genesis
  2. Genesis 123
  3. 3 Genesis
  4. None of the above

Answer to Question 16

Question 17

What is the output of the program?

    void print(char *s)
    {
        if(*s)
            print(++s);
        printf("%c", *s);
    }

    main()
    {
        char str[] = "Genesis";
        print(str);
    }

  1. genesis
  2. sisene
  3. siseneg
  4. None of the above

Answer to Question 17

Question 18

Where will the output of the program be printed?

    main()
    {
        fprintf(stdprn, "Genesis InSoft Limited") ;
    }

  1. Standard output device
  2. Standard error output device
  3. Standard auxiliary device
  4. Standard printer

Answer to Question 18

Question 19

What is the output of the program?

    const int MAX = 15;
    void main()
    {
        enum e{a, b, MAX};
        printf("%d %d %d", a, b, MAX);
    }

  1. 0 1 2
  2. 1 2 3
  3. 1 2 15
  4. 0 1 15

Answer to Question 19

Question 20

What is the purpose of the fcloseall() function?

  1. closes all the streams including standard streams
  2. closes all the streams other than standard streams
  3. closes all the input streams
  4. closes all the output streams

Answer to Question 20

Answers

Answer 1 - B

Back to question 1

Answer 2 - D

Back to question 2

Answer 3 - C

Back to question 3

Answer 4 - C

Back to question 4

Answer 5 - C

Back to question 5

Answer 6 - D

Back to question 6

Answer 7 - B

Back to question 7

Answer 8 - C

Back to question 8

Answer 9 - A

Back to question 9

Answer 10 - B

Back to question 10

Answer 11 - C

Back to question 11

Answer 12 - A

Back to question 12

Answer 13 - C

Back to question 13

Answer 14 - D

Back to question 14

Answer 15 - C

Back to question 15

Answer 16 - A

Back to question 16

Answer 17 - B

Back to question 17

Answer 18 - D

Back to question 18

Answer 19 - A

Back to question 19

Answer 20 - B

Back to question 20

Copyright © 2000 to 2011 Genesis InSoft Limited. All Rights Reserved.