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


b is the correct option





Ques 2 Function


How many minimum numbers of functions are in any C++ Program?
  a) 0
  b) 1
  c) 2
  d) 3


b is the correct option





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


c is the correct option





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


d is the correct option





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


b is the correct option