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

'C' is a

  1. machine language
  2. low level language
  3. middle level language
  4. high level language

Answer to Question 1

Question 2

What is the error in the program? 

    char count; 
    main() 
    { 
        int count = 70; 
        { 
            extern int count; 
            printf("\n %d ", count); 
        } 
    }

  1. Error: Type mismatch in redeclaration of ' nn' 
  2. Error: Multiple declaration for 'nn' 
  3. Error: Storage class 'extern' is not allowed here 
  4. Linker Error: Undefined symbol 'nn' 

Answer to Question 2

Question 3

What is the output of the program?

    void main()
    {
        int val = (5, val = 5)/++val;
        printf("\n %d ", val);
    }

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

Answer to Question 3

Question 4

Which of the following statements is used to return more than one value from a function?

  1. return 1,2,3 ;
  2. return (1,2,3) ;
  3. return ((1), (2), (3)); 
  4. None of the above

Answer to Question 4

Question 5

Which of the following is wrong with respect to structures? 

  1. Having the same name for a structure and its variable 
  2. It has functions as its data members 
  3. It has a data member, which is of the same structure kind 
  4. Both B and C

Answer to Question 5

Question 6

What is the error in the code shown below?

    union 
    { 
        int val1 : 5; 
        char val2; 
    };

  1. Declaration of variables is not possible due to the absence of tag name 
  2. Arrays of this union cannot be created 
  3. Cannot be used in file handling 
  4. All the three B, C and D

Answer to Question 6

Question 7

What is an '&' operator? 

  1. logical 
  2. unary 
  3. bitwise 
  4. ternary 

Answer to Question 7

Question 8

What is the difference between malloc and calloc? 

  1. in allocation of memory 
  2. in return types 
  3. number of arguments 
  4. None of the above

Answer to Question 8

Question 9

What is the default promotion for 'float' in va_arg? 

  1. double 
  2. int 
  3. long int
  4. char

Answer to Question 9

Question 10

What is the error in the program? 

    main() 
    { 
        int a = 12; 
        int *ptr = &a; 
        printf( " %d %d ", *ptr /*ptr, *ptr**ptr); 
    }

  1. No error, output is 1 144

  2. No error, output is 144 144

  3. Unexpected end of file found

  4. Error: illegal pointer operation

Answer to Question 10

Question 11

What is the significance of the function realloc()? 

  1. realloc() adjusts the size of the allocated block to specified size 
  2. realloc() allocates memory on far heap 
  3. It is used to allocate more than 64k bytes 
  4. realloc() allocates the specified number of bytes in registers

Answer to Question 11

Question 12

What is the error in the program?

    main() 
    { 
        typedef struct personal 
        {
             int name[25]:15; 
        } 
        personal; personal person; 
    }

  1. Error: Bit fields must be signed or unsigned int 
  2. Error: Multiple declaration for 'personal' 
  3. Error: Undefined symbol 'personal' 
  4. Error: Size of the type is unknown or zero

Answer to Question 12

Question 13

What is the return type of fflush()? 

  1. void 
  2. FILE* 
  3. char* 
  4. int 

Answer to Question 13

Question 14

What is the error in the program?

    void myprintf()
    {
        printf("\n %d ", printf("Genesis")); 
    }
    
    main() {
        printf("\n %d ", myprintf()); 
    }

  1. Error: Type mismatch in 'printf'
  2. The return type of a function must be an integer 
  3. Error: printf cannot return anything 
  4. Cannot convert from 'void' to '...'

Answer to Question 14

Question 15

What is the meaning of a static function?

  1. It is local to a file in which it is declared 
  2. It is local to main() 
  3. The set of variables used in the function is 'static' 
  4. All the linked files can access it

Answer to Question 15

Question 16

What is the output of the program?

    # include <stdio.h>

    void main()
    {
        int main = 90;
        top : printf("Label1");
        if(main)
            goto top;
    }

  1. Infinite
  2. Label1
  3. No output
  4. label top is invalid

Answer to Question 16

Question 17

How many times is the 'for' loop/statement is executed in the following code. 

    main() 
    { 
        unsigned char ch; 
        for(ch = 0; ch <= 255; ch++); 
    }

  1. Infinite
  2. 255
  3. 256
  4. 127

Answer to Question 17

Question 18

What is maximum number of 'case' values in a switch statement? 

  1. 255 
  2. 127 
  3. No specific limit
  4. 128 

Answer to Question 18

Question 19

What is the output of the program?

    void main()
    {
        int x = (90, x = 90)+++x;
        printf("\n %d ", x);
    }

  1. 90
  2. 1
  3. 181
  4. 91

Answer to Question 19

Question 20

Where do we use a 'continue' statement?

  1. In 'if' statement
  2. In 'switch' statement 
  3. In 'goto' labels 
  4. None of the above

Answer to Question 20

Answers

Answer 1 - C

Back to question 1

Answer 2 - A

Back to question 2

Answer 3 - B

Back to question 3

Answer 4 - D

Back to question 4

Answer 5 - D

Back to question 5

Answer 6 - D

Back to question 6

Answer 7 - C

Back to question 7

Answer 8 - C

Back to question 8

Answer 9 - A

Back to question 9

Answer 10 - C

Back to question 10

Answer 11 - A

Back to question 11

Answer 12 - A

Back to question 12

Answer 13 - D

Back to question 13

Answer 14 - D

Back to question 14

Answer 15 - A

Back to question 15

Answer 16 - A

Back to question 16

Answer 17 - A

Back to question 17

Answer 18 - C

Back to question 18

Answer 19 - C

Back to question 19

Answer 20 - D

Back to question 20

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