1 Crore+ students have signed up on EduRev. Have you? |
What are mandatory parts in the function declaration?
In a function, return type and function name are mandatory all else are just used as a choice.
How many can max number of arguments present in function in the c99 compiler?
C99 allows to pass a maximum of 127 arguments in a function.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void mani()
void mani()
{
cout<<"hai";
}
int main()
{
mani();
return 0;
}
We have to use the semicolon to declare the function in line 3. This is called a function declaration and a function declaration ends with a semicolon.
What is the scope of the variable declared in the user defined function?
The variable is valid only in the function block as in other.
Normally the execution of the program in c++ starts from main only.
which of the following is used to terminate the function declaration?
semicolon is used to terminate a function declaration statement in C++.
Which is more effective while calling the functions?
In the call by reference, it will just passes the reference of the memory addresses of passed values rather than copying the value to new memories which reduces the overall time and memory use.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void fun(int x, int y)
{
x = 20;
y = 10;
}
int main()
{
int x = 10;
fun(x, x);
cout << x;
return 0;
}
In 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
How many minimum number of functions should be present in a C++ program for its execution?
The execution of a C++ program starts from main function hence we require atleast 1 function to be present in a C++ program to execute and i.e. the main function.
As it is used to execute a block of code, So we will not allocate or deallocate memory.
15 videos|20 docs|13 tests
|
Use Code STAYHOME200 and get INR 200 additional OFF
|
Use Coupon Code |
15 videos|20 docs|13 tests
|
|
|
|
|
|
|
|