github

Made bySaurav Hathi

MCQ Test C/C++: Functions and Recursion 2

Q1:

What is the output of this C++ program?

#include <iostream>

using namespace std;

void print(int i)

{

cout << i;

}

void print(double  f)

{

cout << f;

}

int main(void)

{

print(5);

print(500.263);

return 0;

}

Tags:
Section:
Core Programming
Options:
Q2:

What will be the output of below C++ program?

#include <iostream>

using namespace std;

int Add(int X, int Y, int Z)

{

return X + Y;

}

double Add(double X, double Y, double Z)

{

return X + Y;

}

int main()

{

cout << Add(5, 6);

cout << Add(5.5, 6.6);

return 0;

}

Tags:
Section:
Core Programming
Options:
Q3:

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

#include <iostream>

using namespace std;

int operate (int a, int b)

{

return (a * b);

}

float operate (float a, float b)

{

return (a / b);

}

int main()

{

int x = 5, y = 2;

float n = 5.0, m = 2.0;

cout << operate(x, y) <<" ";

cout << operate (n, m);

return 0;

}

Tags:
Section:
Core Programming
Options:
Q4:

What will be the output of this C++ code?

#include <iostream>

using namespace std;

class Test

{

public:

Test() { cout << "Hello from Test() "; }

} a;

int main()

{

cout << "Main Started ";

return 0;

}

Tags:
Section:
Core Programming
Options:
Q5:

What is the output of this C code?

#include <stdio.h>

int main()

{

void foo();

printf("1 ");

foo();

}

void foo()

{

printf("2 ");

}

Tags:
Section:
Core Programming
Options:
Q6:

What is the output of this C code?

#include <stdio.h>

int main()

{

void foo(), f();

f();

}

void foo()

{

printf("2 ");

}

void f()

{

printf("1 ");

foo();

}

Tags:
Section:
Core Programming
Options:
Q7:

What is the output of this C code?

#include <stdio.h>

int main()

{

void foo();

void f()

{

foo();

}

f();

}

void foo()

{

printf("2 ");

}

Tags:
Section:
Core Programming
Options:
Q8:

What is the output of this C code?

#include <stdio.h>

void foo();

int main()

{

void foo();

foo();

return 0;

}

void foo()

{

printf("2 ");

}

Tags:
Section:
Core Programming
Options:
Q9:

What is the output of this C code?

#include <stdio.h>

void fun();

int main()

{

void fun(int);

fun(1);

return 0;

}

void fun(int i)

{

printf("2 ");

}

Tags:
Section:
Core Programming
Options:
Q10:

What is the output of this C code?

#include <stdio.h>

void fun();

int main()

{

void fun(int);

fun();

return 0;

}

void fun()

{

printf("2 ");

}

Tags:
Section:
Core Programming
Options:
Q11:

What is the output of this C code?

#include <stdio.h>

void me()

{

printf("hi");

}

int main()

{

me();

}

Tags:
Section:
Core Programming
Options:
Q12:

What is the output of this C code?

#include <stdio.h>

void me();

void ne()

{

me();

}

int main()

{

void me()

{

printf("hi");

}

}

Tags:
Section:
Core Programming
Options:
Q13:

What is the output of this C code?

#include <stdio.h>

void me()

{

printf("hi");

me();

}

int main()

{

me();

}

Tags:
Section:
Core Programming
Options:
Q14:

What is the output of the given C code?

#include <stdio.h>

void fun()

{

return 1;

}

int main()

{

int x = 0;

x = fun();

printf("%d", x);

}

Tags:
Section:
Core Programming
Options:
Q15:

What is the output of this C++ program?

#include <iostream>

using namespace std;

void addprint()

{

static int s = 1;

s++;

cout << s;

}

int main()

{

addprint();

addprint();

addprint();

return 0;

}

Tags:
Section:
Core Programming
Options: