Exercise

1.What is the output of this program?
Note:Includes all required header files

using namespace std;
void find()
void find()
{
cout<<"course";
}
int main()
{
find();
return 0;
}

A. course
B. coursecourse
C. compile time error
D. none of the mentioned

View Answer


2.What is the output of this program?
Note:Includes all required header files

using namespace std;
void fun(int p, int q)
{
p = 20;
q = 10;
}
int main()
{
int p = 10;
fun(p, p);
cout << p;
return 0;
}

A. 10
B. 20
C. compile time error
D. none of the mentioned

View Answer


3.What is the output of this program?
Note:Includes all required header files

using namespace std;
void copy (int& a, int& b, int& c)
{
a *= 2;
b *= 2;
c *= 2;
}
int main ()
{
int x = 2, y = 5, z = 7;
copy (x, y, z);
cout << "x =" << x << ", y =" << y << ", z =" << z;
return 0;
}

A. 3 7 10
B. 3 6 5
C. 4 10 14
D. none of the mentioned

View Answer


4.What is the output of this program?
Note:Includes all required header files

using namespace std;
void fun(int &p)
{
p = 30;
}
int main()
{
int p = 5;
fun(p);
cout << "New value of p is " << p;
return 0;
}

A. 5
B. 30
C. 15
D. none of the above

View Answer


5.Which of the following is true about the following program
Note:Includes all required header files

using namespace std;
long factorial (long p)
{
if (p > 1)
return (p * factorial (p + 1));
else
return (1);
}
int main ()
{
long q = 3;
cout << q << "! = " << factorial ( q );
return 0;
}

A. 6
B. 24
C. segmentation fault
D. compile time error

View Answer


6.What will be the output of this program?
Note:Includes all required header files

using namespace std;
void square (int *p)
{
*p = (*p + 1) * (*p);
}
int main ( )
{
int q = 5;
square(&q);
cout << q;
return 0;
}

A. 25
B. compile time error
C. 36
D. 30

View Answer


7.What will be the output of this program?
Note:Includes all required header files

using namespace std;
int max(int p, int q )
{
return ( p > q ? p : q );
}
int main()
{
int x = 25;
int y = 50;
cout << max(x, y );
return 0;
}

A. 25
B. 50
C. either 25 or 50
D. none of the mentioned

View Answer


8. What will be the output of the following program?
Note:Includes all required header files

using namespace std;
int gcd (int a, int b)
{
int temp;
while (b != 0)
{
temp = a % b;
a = b;
b = temp;
}
return(a);
}
int main ()
{
int x = 7, y = 13;
cout << gcd(x, y);
return(0);
}

A. 7 B. 13 C. 91 D. 1

View Answer


9. What will be the output of the following program?
Note:Includes all required header files

using namespace std;
void find(int p)
{
cout << p;
}
void find(double q)
{
cout << q;
}
int main(void)
{
find(5);
find(555.263);
return 0;
}

A. 5555.263
B. 555.2635
C. 555.263
D. None of the mentioned

View Answer


10. What will be the output of the following program?
Note:Includes all required header files

using namespace std;
int find (int a, int b)
{
return (a * b);
}
float find (float a, float b)
{
return (a / b);
}
int main()
{
int x = 5, y = 2;
float n = 5.0, m = 2.0;
cout << find(x, y) <<"\t";
cout << find (n, m);
return 0;
}

A. 10.0 5.0
B. 5.0 2.5
C. 10.0 5
D. 10 2.5

View Answer



Discussion

* You must be logged in to add comment.