QUESTIONS WITH ACCURATE SOLUTIONS
RATED A.
Given the following function definition:
void calc (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 calc?
int x = 1;
int y = 2;
int z = 3;
calc (x, y);
cout << x << ", " << y << ", " << z << endl;
1, 6, 3
T/F. Function without prototypes need to be before main () to be able to use
the in the main.
True
This function causes a program to terminate, regardless of which function or
control mechanism is executing.
,exit()
What is the output of the following program?
const int LIMIT = 50;
int AddEm (int x, int y);
}
int main ()
{
int x = 42, y = 35;
int total;
total = AddEm (x, y);
cout << "Total is: " << total << endl;
return 0;
}
int AddEm (int x, int y)
{
int total;
total = x + y;
if (total > LIMIT)
total = 0;
return (total);
}
None of these
- 50
- 42
- 35
- 77
,What is the output of the following program?
void showDub (int);
int main ()
{
int x = 2;
showDub (x);
cout << x << endl;
return 0;
}
void showDub (int num)
{
cout << (num * 2) << endl;
}
4
2
What is the output of the following program?
void doSomething (int);
int main ()
{
int x = 2;
cout << x << endl;
doSomething (x);
cout << x << endl;
return 0;
}
void doSomething (int num)
{
, num = 0;
cout << num << endl;
}
2
0
2
What is the output of the following program?
void doSomething (int&);
int main ()
{
int x = 2;
cout << x << endl;
doSomething (x);
cout << x << endl;
return 0;
}
void doSomething (int& num)
{
num = 0;
cout << num << endl;
}
2
0
0
What is the output of the following program?
int x = 1, y = 2, z = 3;
bool checkIt (int num);