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