C Programming - Basics of Functions
Question 1
|
What is the output of this C code?
1 2
| |
Compile time error
| |
1 2 1 2
| |
Depends on the compiler
|
Question 2
|
What is the output of this C code?
Compile time error as foo is local to main
| |
1 2
| |
2 1
| |
Compile time error due to declaration of functions inside main
|
Question 3
|
What is the output of this C code?
2 2
| |
2
| |
Compile time error
| |
Depends on the compiler
|
Question 4
|
What is the output of this C code?
Compile time error
| |
2
| |
Depends on the compiler
| |
Depends on the standard
|
Question 5
|
What is the output of this C code?
2
| |
Compile time error
| |
Depends on the compiler
| |
Depends on the standard
|
Question 6
|
What is the output of this C code?
2
| |
Compile time error
| |
Depends on the compiler
| |
Depends on the standard
|
Question 7
|
What is the output of this C code?
hi
| |
Run time error
| |
Nothing
| |
Varies
|
Question 8
|
What is the output of this C code?
hi
| |
Run time error
| |
Nothing
| |
Varies
|
Question 9
|
What is the output of this C code?
hi
| |
Compile time error
| |
Nothing
| |
Varies
|
Question 10
|
What is the output of this C code?
hi
| |
Compile time error
| |
Nothing
| |
Varies
|
Question 11
|
What is the output of this C code?
Compile time error
| |
hi
| |
Infinite hi
| |
Nothing
|
Question 12
|
What is the output of this C code?
Run time error
| |
hi
| |
Infinite hi
| |
hi hi
|
Question 13
|
Which of the following is a correct format for declaration of function?
return-type function-name(argument type);
| |
return-type function-name(argument type) {}
| |
return-type (argument type)function-name;
| |
Both (a) and (b)
|
Question 14
|
Which of the following function declaration is illegal?
int 1bhk(int);
| |
int 1bhk(int a);
| |
int 2bhk(int*, int []);
| |
All of the mentioned
|
Question 15
|
Which function definition will run correctly?
int sum(int a, int b) return (a + b);
| |
int sum(int a, int b) {return (a + b);}
| |
int sum(a, b) return (a + b);
| |
Both (a) and (b)
|
Question 16
|
Can we use a function as a parameter of another function? [ Eg: void wow(int func()) ]
Yes, and we can use the function value conveniently
| |
Yes, but we call the function again to get the value, not as convenient as in using variable
| |
No, C does not support it.
| |
This case is compiler dependent
|
Question 17
|
The value obtained in the function is given back to main by using ________ keyword?
return
| |
static
| |
new
| |
volatile
|
Check Your Answers:
1. A
2. B
3. D
4. B
5. A
6. B
7. A
8. A
9. B
10. B
11. C
12. D
13. A
14. D
15. B
16. C
17. A
0 comments:
Post a Comment