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.
Question1
Reusability of code in C is supported by
- Functions
- Macros
- Pointers
- Files
Answer to Question 1
Question 2
The entry point of the 'C' program is with
- #include
- main(int argc, char * argv)
- c_main
- MAIN()
Answer to Question 2
Question 3
When a const variable is declared, it is stored
- in RAM
- in ROM
- on heap
- in CPU registers
Answer to Question 3
Question 4
What is the output of the program?
#include <stdio.h>
int main(int argc, char *argv[])
{
printf(" %d", printf("Hello
Genesis"));
return 0;
}
- Hello Genesis
- 13 Hello Genesis
- Hello Genesis 13
- None of the above
Answer to Question 4
Question 5
What is the output of the program?
#include <stdio.h>
void main()
{
printf("\n Hi" " %s ",
"Genesis"" InSoft");
}
- Hi %s Genesis InSoft
- Hi Genesis
- Hi Genesis InSoft
- Hi %s Genesis InSoft
Answer to Question 5
Question 6
What is the output of the program?
#include <stdio.h>
main()
{
switch (5)
{
case 5: printf(" 5
");
default: printf("
10 ");
case 6: printf(" 6
");
}
}
- 5
- 5 10
- 5 10 6
- 5 6
Answer to Question 6
Question 7
What is the output of the program?
#include <stdio.h>
void main()
{
int x = 9;
Continue: printf("\n Continue ");
if(!x)
goto gen;
gen: printf(" Genesis ");
}
- Genesis
- Continue Genesis
- Continue
- None of the above
Answer to Question 7
Question 8
Which argument of function 'strncmp()' specifies number of characters to be compared?
- first
- second
- third
- fourth
Answer to Question 8
Question 9
Which of the following is not a storage class in C?
- Static
- Register
- Extern
- Stack
Answer to Question 9
Question 10
Which of the following 'return' statement is correct?
- return, return;
- return(1, 2, 3);
- return(return 4);
- (return 5, return 6);
Answer to Question 10
Question 11
The second argument to fopen() function is?
- char
- const char *
- int *
- FILE *
Answer to Question 11
Question 12
What is the data type of FILE?
- integer
- union
- pointer
- structure
Answer to Question 12
Question 13
The first argument of fwrite function is typecast to
- char *
- FILE *
- int *
- void *
Answer to Question 13
Question 14
Which of the following storage class variables cannot be used with pointers?
- extern
- static
- register
- Both A and C
Answer to Question 14
Question 15
What is the output of the program?
#include <stdio.h>
void main()
{
int (*myprintf)(const char*, ...) = printf;
myprintf("Genesis InSoft Limited");
}
- Genesis InSoft Limited
- No output
- Undefined symbol myprintf
- Prototype mismatch
Answer to Question 15
Question 16
What is the output of the program?
#include <stdio.h>
void main()
{
char buffer[10] = {"Genesis"};
printf(" %d ", &buffer[4]-
(buffer));
}
- 3
- 4
- 0
- Illegal pointer subtraction
Answer to Question 16
Question 17
If "arr" is an array of 5 x 5 dimension, arr[2][4] is same as
- **(a+3+4)
- *(a+3)+*(a+4)
- **(a+3)+4
- *(*(a+2)+4)
Answer to Question 17
Question 18
What is the significance of the free() function?
- It erases the contents of any type and cleans the pointer
- It places the memory address with the pointer in free store
- It assigns the pointer a NULL value
- It disables the memory address with the pointer
Answer to Question 18
Question 19
The following statement is used in C for
char *ptr = (char*) malloc(Length);
- For faster execution of programs
- For reducing the code
- For conservation of memory
- Both A and B
Answer to Question 19
Question 20
What is the output of the program?
#include <stdio.h>
#define sq(a) a * a
void main()
{
printf("%d", sq(3 + 2));
}
- 25
- 11
- 10
- Compilation error
Answer to Question 20
Answers
Answer 1 - A
Back to question 1
Answer 2 - B
Back to question 2
Answer 3 - B
Back to question 3
Answer 4 - C
Back to question 4
Answer 5 - C
Back to question 5
Answer 6 - C
Back to question 6
Answer 7 - B
Back to question 7
Answer 8 - C
Back to question 8
Answer 9 - D
Back to question 9
Answer 10 - B
Back to question 10
Answer 11 - B
Back to question 11
Answer 12 - D
Back to question 12
Answer 13 - D
Back to question 13
Answer 14 - C
Answer 15 - A
Back to question 15
Answer 16 - B
Back to question 16
Answer 17 - D
Answer 18 - B
Answer 19 - C
Back to question 19
Answer 20 - B
Back to question 20
|