Can someone please help me with this midterm questions? All the answers should b
ID: 3862208 • Letter: C
Question
Can someone please help me with this midterm questions? All the answers should be related to C++ language. Thank you is advance.
1)
while (i < target)
{
...
i++
}
What data type should i and target be declared as?
a) float b) double c) char d) int
2)
How many times will the statement k = i *j; in the code below be executed?
int i, j, k;
for (i = 0; i < 10; i++)
for (j = 0; j < 10; j++)
k = i *j;
a) 1 b) 10 c) 81 d) 100
3)
double processValue (int val);
int value = 23;
double result = processValue (value);
For the code shown above, what is the:
* name of the formal parameter:
* name of the argument:
* name of the variable assigned the value returned from processValue:
4)
const int MAX = 7;
int main (int argc, char *argv[])
{
int count = 0;
while (count <= MAX)
{
cout << count << endl;
count++;
}
}
* The name of the loop control variable for the code above is:
* This loop will execute: _____ times.
Explanation / Answer
(1) (d) Int
(2) (d) 100
(3)
name of the formal parameter (int val)
name of the argument: value
name of the variable assigned the value returned from processValue:result
(4)
The name of the loop control variable for the code above is: Count
* This loop will execute: _____8 times.
(4)