Function Declarations(C++ Programming ) Questions and Answers
Explanation:-
Answer: Option B. -> 1The main function is the mandatory part, it is needed for the execution of the program to start.
Explanation:-
Answer: Option B. -> only inside the {} blockThe variable is valid only in the function block as in other.
Question 3.
What is the output of this program?
1.
#include
2.
using namespace std;
3.
void fun(int x, int y)
4.
{
5.
x = 20;
6.
y = 10;
7.
}
8.
int main()
9.
{
10.
int x = 10;
11.
fun(x, x);
12.
cout
- 10
- 20
- compile time error
- none of the mentioned
Explanation:-
Answer: Option A. -> 10In this program, we called by value so the value will not be changed, So the output is 10
Output:
$ g++ fun.cpp
$ a.out
10
Question 4.
What is the output of this program?
1.
#include
2.
using namespace std;
3.
void mani()
4.
void mani()
5.
{
6.
cout
- hai
- haihai
- compile time error
- none of the mentioned
Explanation:-
Answer: Option C. -> compile time errorWe have to use the semicolon to declare the function in line 3. If we did means, the program
will execute.
Explanation:-
Answer: Option B. -> call by referenceIn the call by reference, it will just copy the address of the variable to access it, so it will reduce
the memory in accessing it.
Explanation:-
Answer: Option D. -> 127None.
Explanation:-
Answer: Option B. -> main functionNormally the execution of the program in c++ starts from main only.
Explanation:-
Answer: Option C. -> ;None.
Explanation:-
Answer: Option A. -> return type,function nameIn a function, return type and function name are mandatory all else are just used as a choice.