- Which one of the following statements is a valid main function prototype?
- void main ( );
- int main (int a, int b)
main (int argc, char argv);
- int main(int argc, char* argv[ ]);
- Which one of the following is true about a function in a C++ program?
A function must be called at least once.
- A function may called as and when required.
- A function can be called only by the main function.
- A function must always return a value.
- Which of the following function prototypes is invalid?
- void exchange (int, int);
void exchange (int a, int b);
- void exchange (int x, y);
- void exchange (float, int);
- Find the error in the following function prototype double area (int)
Argument name is not specified
- Semicolon at the end is missing
- Return type and argument type must be same
- No error
In C++, the main function returns to the operating system
- an integer value
a floating point value
- address of the function
- none of the above
- The ‘call by reference’ approach of invoking a function enables us to
- copy the values of arguments into the calling function
not to alter the values of the original variables in the calling program
- change the values of the variables in the calling program
- use the function on the left-hand side of an assignment statement
- Following is a list of function declarations with default values. Which one of them is a valid declaration?
- float mul(float a=5.0, b=10.0);
- float mul(int a, float b=10.0, int c);
float mul(int a=5, float b);
- float mul(int a, float b=10.0);
- The following is the list of function declarations. Which one of them will be invoked by the function call statement cout <<mul(10.5, 10);
- int mul(int a, int b);
- double mul(float a, float b);
double mul(int a, double b);
- int mul(float a, int b);
- The usage of macros in C may be replaced in C++ by
friend functions
- inline functions
- virtual function
- functions with default arguments
- The below function
- mul(void)
- {
- return(5.5 * 3);
- }
- when executed will return
- a) 16
- b) 16.5
c) 16.0
- d) error
- Which of the following statements is true in respect of a function containing const arguments?
The function cannot return a value.
- The function cannot change the value of const arguments.
- const should be used for the argument passed by reference.
- const argument cannot be used in any expression.
- Which of the following will return the value –8.0 given the value of x to be –8.5?
- fabs(x)
ceil(x)
- floor(x)
- all the above
Answers:
- int main(int argc, char* argv[ ]);
- A function may called as and when required.
- void exchange (int x, y);
- Semicolon at the end is missing
- an integer value
- change the values of the variables in the calling program
- float mul(int a, float b=10.0);
- int mul(float a, int b);
- inline functions
- error
- The function cannot change the value of const arguments.
- floor(x)
You must log in to post a comment.