Question: In C++ Programming: HW Questions int count (int num ) { int result = 0; while (num > 1) { result += num; --num; }
In C++ Programming: HW Questions
int count (int num )
{
int result = 0;
while (num > 1)
{
result += num;
--num;
}
return result;
}
count (1);
What is the return value of the following function call?
Given the following code,
string text(string input) { return input;
input = "Goodbye"; } What is the output of the following statements?
string stuff = "Hello";
cout << stuff << endl;
cout << text(stuff) << endl;
cout << stuff << endl;
Given the function prototype: double testAlpha(int u, char v, double t); which of the following statements is legal? cout << testAlpha(5, 'A', 2); cout << testAlpha( int 5, char 'A', int 2); cout << testAlpha('5.0', 'A', '2.0'); cout << testAlpha(5.0, "65", 2.0);
const int MAX = 100;
string validator( bool valid) { return valid ? "yes" : "no"; } What is the return value of the following function call?
validator(30 <= MAX / 2);
Given the following function:
int strange(int num1, int num2) { if (num1 > num2) return num1 + num2; else return num1 num2; }
what is the output of the following statement?
cout << strange(4, 5) << endl;
Which statement below about prototypes and headers is true? Parameter names must be listed in the prototype, but not necessarily in the header. Prototypes end with a semicolon, but headers do not. Headers should come before prototypes. Headers end with a semicolon, but prototypes do not.
The output of the statement:
cout << pow(2.0, pow(3.0, 1.0)) << endl;
is ____. 6.0 7.0 8.0 9.0
Given the following code,
int foo(char letter) { switch(letter) { case 'a': case 'b': case 'c': return letter - 'a'; }
return 4; } What is the value of val of the following function call?
char test = 'c' - 1; int val = foo(test); 'a'
'b'
0
1
2
3
4
'b' - 'a'
Given the following code,
int count (int num ) { int result = 0;
while (num > 1) { result += num; --num; }
return result; } What is the return value of the following function call?
int test = 3; count (test );
The following function heading in a C++ program is valid:
int funcExp(int u, char v, double g)
True
False
Once you write and properly debug a function, you can use it in the program (or different programs) again and again without having to rewrite the same code repeatedly. True
False
If the formal parameter list of a function is empty, the parentheses after the function name are not needed. True
False
The execution of a return statement in any user-defined function terminates the entire program.
True
False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
