1. Determine the output of each of the following program when it is executed. (a)
#include using namespace std; int main()
{
int min(int, int); oat min( oat, oat);
double min(double,double); int a = 10,b = 20;
oat fa = 1.1, fb = -2.2; double da = 100,db = 300;
cout <><><><><><>
}
int min(int a,int b)
{
return (a <>
}
oat min( oat a, oat b)
{
return (a <>
}
double min(double a, double b)
{
return (a <>
}
(b)
#include using namespace std; int main()
{
void display(); void display (int);
void display(int, int);
void display(int, int, int); int a = 10, b = 20, c = 30; if ( a++ > ++b)
display(a);
else if (b++ > ++c) display(b,c);
else if ( b > ++c || a > c) display(a,b,c);
else
display(); return 0;
}
void display(int a)
{
cout <><>
}
void display(int b, int c)
{
cout <><>endl; cout <><> endl;
}
void display(int a, int b, int c)
{
cout <><>endl; cout <><>endl; cout <><> endl;
}
void display()
{
cout <>
}
(c)
#include using namespace std; int main()
{
void display(); void display (int);
void display(int, int);
void display(int, int, int); int a = 10, b = 20, c = 30; if (a++ > ++b)
display(a);
else if (b++ > ++c) display(b,c);
else if ((b <><>
else
display(); return 0;
}
void display(int a)
{
cout <><>
}
void display(int b, int c)
{
cout <><>endl; cout <><> endl;
}
void display(int a, int b, int c)
{
cout <><>endl; cout <><>endl; cout <><> endl;
}
void display()
{
cout <>
}
(d)
#include #include using namespace std; int main()
{
void display();
void display (string);
void display(string, string);
void display(string, string, string); string str1 = “Hello”;
string str2 = “C++”; string str3 = “world”; int x = 10, y = 3;
int temp = ++x % ++y; switch (temp) {
case 10:
display(); break;
case 3:
display(str1,str2,str3); break;
case 4:
display(str1);
break; case 11:
display (str1,str2); break;
}
return 0;
}
void display()
{
cout <>
}
void display(string a)
{
cout <><>
}
void display(string b, string c)
{
cout <><><><><>
}
void display(string a, string b, string c)
{
}
(e)
cout <><><><><><><><>
#include #include using namespace std; class abc {
public:
void display();
void display (string);
void display(string, string);
void display(string, string, string);
};
int main()
{
abc obj;
string str1 = “Hello”; string str2 = “C++”; string str3 = “world”; int x = 11, y = 3;
int temp = ++x % y++; switch (temp) {
case 10:
obj.display(); break;
case 3:
obj.display(str1,str2,str3);
break; case 4:
obj.display(str1); break;
case 0:
obj.display (str1,str2); break;
}
return 0;
}
void abc :: display()
{
cout <>
}
void abc :: display(string a)
{
cout <><>
}
void abc :: display(string b, string c)
{
cout <><><><><>
}
void abc :: display(string a, string b, string c)
{
}
(f)
cout <><><><><><><><>
#include #include using namespace std; class abc {
public:
void seta(int a[]); void setfa( oat fa[]); int sum(int a[]);
oat sum ( oat fa[]);
};
void abc :: seta(int a[])
{
for (int i = 0; i <=>
}
void abc :: setfa( oat fa[])
{
for (int i = 0; i <=>
}
int abc :: sum(int a[])
{
int temp = 0;
for (int i = 0; i <=>
return (temp);
}
oat abc :: sum( oat a[])
{
oat temp = 0;
for (int i = 0; i <=>
return (temp);
}
int main()
{
abc obj; int a[10];
oat fa[10]; obj.seta(a); obj.setfa(fa);
cout <><><><><><>
}
=>=>=>=>