This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Functions”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What will be the output of the following C code?
#include <stdio.h>
void main()
{
m();
void m()
{
printf("hi");
}
}
a) hi
b) Compile time error
c) Nothing
d) Varies
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
void main()
{
m();
}
void m()
{
printf("hi");
m();
}
a) Compile time error
b) hi
c) Infinite hi
d) Nothing
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
void main()
{
static int x = 3;
x++;
if (x <= 5)
{
printf("hi");
main();
}
}
a) Run time error
b) hi
c) Infinite hi
d) hi hi
View Answer
Explanation: None.
4. Which of the following is a correct format for declaration of function?
a) return-type function-name(argument type);
b) return-type function-name(argument type){}
c) return-type (argument type)function-name;
d) all of the mentioned
View Answer
Explanation: None.
5. Which of the following function declaration is illegal?
a) int 1bhk(int);
b) int 1bhk(int a);
c) int 2bhk(int*, int []);
d) all of the mentioned
View Answer
Explanation: None.
6. Which function definition will run correctly?
a)
int sum(int a, int b) return (a + b);
b)
int sum(int a, int b) {return (a + b);}
c)
int sum(a, b) return (a + b);
d) none of the mentioned
View Answer
Explanation: None.
7. Can we use a function as a parameter of another function? [Eg: void wow(int func())].
a) Yes, and we can use the function value conveniently
b) Yes, but we call the function again to get the value, not as convenient as in using variable
c) No, C does not support it
d) This case is compiler dependent
View Answer
Explanation: None.
8. The value obtained in the function is given back to main by using ________ keyword.
a) return
b) static
c) new
d) volatile
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Apply for C Internship
- Check Computer Science Books
- Practice BCA MCQs
- Watch Advanced C Programming Videos
- Check C Books