Function in C++ MCQs Exercise I

Ques 1 Function


The execution of a C++ Program starts with the?

A user define function
B main function
C void function
D All of these

Ques 2 Function


How many minimum numbers of functions are in any C++ Program?

A 0
B 1
C 2
D 3

Ques 3 Function


Which of the following correct way to define a function with default arguments?

A int sum(int x=10,int y,int z){}
B int sum(int x=10,int y,int z){}
C int sum(int x,int y=10,int z=20){}
D All of these

Ques 4 Function


What is the output of the following C++ Code?


#include <iostream>
using namespace std;
int sum(int a=10, int b=20, int c){
    return a+b+c;
}
int main()
{
    cout<< sum(30);
}

A 60
B 30
C 70
D Error

Ques 5 Function


What is the output of the following C++ Code?


#include <iostream>
using namespace std;
int temp()
{
    static int x=10;
    cout<<x<<" ";
    x+=2;
}
int main()
{
    temp();
    temp();
}

A 10 10
B 10 12
C 0 10
D Error