Q.6.
Give the output of the following:
#include<iostream> using namespace std; void abc(int n1=10,int n2=20) { cout<<n1+n2<<endl; } void abc(int n1=10,int n2=20,int n3=30) { cout<<n1+n2+n3<<endl; } int main() { //int x=10,y=20,x=30; //abc(); //abc(x,y); abc(100,200,300); return 0; }
a) 30
b) 60
c) 600
d) Error
Q.7.
What will be the output of the following C++ code?
#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; }
a) 5500.263
b) 500.2635
c) 500.263
d) Error
Q.8.
What will be the output of the following C++ code?
#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; }
a) 11 12.1
b) 12.1 11
c) 11 12
d) compile time error
Q.9.
What will be the output of the following C++ code?
#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) <<"\t"; cout << operate (n, m); return 0; }
a) 10.0 5.0
b) 5.0 2.5
c) 10.0 5
d) 10 2.5
Q.10.
Overloaded functions are ________________
a) Very long functions that can hardly run
b) One function containing another one or more functions inside it
c) Two or more functions with the same name but different number of parameters or type
d) Very long functions