C Functions-1
1. Choose correct statement about Functions in C Language.
a) A Function is a group of c statements which can be reused any number of times
b) Every Function has a return type
c) Every Function may no may not return a value
d) All the above
Answer: D
No explanation is given for this question.
2. Choose a correct statement about C Function?
void main() {
printf("Hello");
}
a) "main" is the name of default must and should Function
b) main() is same as int main()
c) By default, return 0 is added as the last statement of a function without specific return type
d) All the above
Answer: D
No explanation is given for this question.
3. A function which calls itself is called a ___ function.
a) Self Function
b) Auto Function
c) Recursive Function
d) Static Function
Answer: C
No explanation is given for this question.
4. The keyword used to transfer control from a function back to the calling function is
int **a;
a) switch
b) goto
c) go back
d) return
Answer: D
The keyword return is used to transfer control from a function back to the calling function.
5. How many times the program will print "Algbly"?
int main() {
printf("Algbly");
main();
return 0;
}
a) Infinite times
b) 32767 times
c) 65535 times
d) Till stack overflows
Answer: D
A call stack or function stack is used for several related purposes, but the main reason for having one is to keep track of the point to which each active subroutine should return control when it finishes executing.
A stack overflow occurs when too much memory is used on the call stack.
Here function main() is called repeatedly and its return address is stored in the stack. After stack memory is full. It shows stack overflow error.
6. Determine Output :
void show() {
printf("PISTA ";
show();
}
void main() {
printf("CACHEW ");
return 10;
}
a) PISTA CACHEW
b) CASHEW PISTA
c) PISTA CASHEW with compiler warning
d) Compiler error
Answer: C
Here show() function should not return anything. So, return 10; is not recommended.
7. What are the types of functions in C Language?
a) Library Functions
b) User Defined Functions
c) Both Library and User Defined
d) None of the above
Answer: C
No explanation is given for this question.
8. Choose correct statements about C Language Pass By Value.
a) Pass By Value copies the variable value in one more memory location
b) Pass By Value does not use Pointers
c) Pass By Value protects your source or original variables from changes in outside functions or called functions
d) All the above
Answer: D
No explanation is given for this question.
9. What is the limit for number of functions in a C Program?
a) 16
b) 31
c) 32
d) No Limit
Answer: D
There is no limit on the number of functions.
10. Every C Program should contain which functionEvery C Program should contain which function?
a) printf()
b) show()
c) scanf()
d) main()
Answer: D
main() is a compulsory function with or without returning anything.