Question
This is C++ 1 . ) Given the function definition: void something (int a, int&b) { int c; c= a + 2; a= a *
This is C++
1.) Given the function definition:
void something (int a, int&b)
{
int c;
c= a + 2;
a= a * 3;
b= c + a;
}
what is the output of the following code fragment that invokes something?
(All variables are of type int.)
r= 1;
s=2;
t=3;
something(t, s)
cout<
a. 1 14 3
b. 1 10 3
c. 5 14 3
d. 1 14 9
e. None of these
2.) What is the output of the following code fragments?
int trial(int&a, int b)
{
if(b>a)
{
a=b;
return -a;
}
else
{
return 0;
}
}
int x= 0, y=10,z;
z= trial(y,x);
cout<
a. -10 0 0
b. 0 10 0
c. 10 0 0
d. 0 0 10
3.) What does the following function do?
double min(int x, int y, int z){
if(x>y){
if (y>z) return z;
else return y;
}
else{
if (x>z) return z;
else return x;
}
}
a. returns the minimum value among x, y, and z
b. it actually return the maximum value among x, y, and z although the function name is min
c. there is a syntax error
d. there is a logical error
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started