Skip to main content

io

1).What is the correct way to declare a function in C++?

1) void functionName()
2) functionName() void
3) function void()
4) None of the above

2).Which of the following is the correct syntax for passing arguments to a function in C++?

1) functionName(arg1, arg2)
2) functionName{arg1, arg2}
3) functionName[arg1, arg2]
4) functionName(arg1: arg2)

3).What is the purpose of the `return` statement in C++ functions?

1) To stop the function execution
2) To return a value to the calling function
3) To pass control to the next function
4) To call another function

4).Which of the following is true about function overloading in C++?

1) Functions with the same name but different parameter types can be overloaded
2) Functions with the same name and parameters cannot be overloaded
3) Function overloading is not allowed in C++
4) None of the above

5).What will happen if a function does not have a return statement in C++?

1) The program will terminate
2) The function will return a random value
3) The function will not return anything
4) Compilation error

6).Which keyword is used to define a function in C++ that does not return any value?

1) void
2) return
3) static
4) None of the above

7).Which of the following is a valid recursive function in C++?

1) int factorial(int n) { if (n == 0) return 1; else return n * factorial(n-1); }
2) int factorial(int n) { return n * factorial(n); }
3) int factorial(int n) { return n; }
4) None of the above

8).What does the `inline` keyword do in C++?

1) It tells the compiler to insert the function code directly at the point of call
2) It defines a function with no return type
3) It ensures the function is only called once
4) None of the above

9).What is the correct way to declare a function that returns a pointer to an integer in C++?

1) int* functionName()
2) int functionName*()
3) int* functionName*()
4) None of the above

10).Which of the following is the correct syntax for passing a reference to a function in C++?

1) functionName(int& x)
2) functionName(&int x)
3) functionName(int* x)
4) None of the above