Question: C++ home work ________________________________ 1a) int addition (int a, int b) { int r; r=a+b; } What is wrong with this function? The parameter list

C++ home work ________________________________ 1a) int addition (int a, int b) { int r; r=a+b; } 

What is wrong with this function?

The parameter list is wrong
The variable definition is wrong
The calculation is wrong

Something is missing

_______________________________

2b)You wish to determine whether the contents of var1 and var2 are not equal. What is missing?

if(var1 _____ var2)

___________________________________

4)

Which would you use to get an unknown number of values entered by a user?

loop
else statement
case statement
if statement

Which type of variable is total and what is it used for?

void countUp() { int total = 0; for (int i = 0; i < 100; i++) { std::cout << i<< std::endl; total = total + i; }

______________________________________

5c)

Which type of variable is total and what is it used for?

void countUp() { int total = 0; for (int i = 0; i < 100; i++) { std::cout << i<< std::endl; total = total + i; }

a) A counter variable. It is used to determine the number of times the loop will repeat.

b) An accumulator variable. It is used to store the sum of all i values

_____________________________________________

6)

Consider the following code. Why would you get identifier not found errors?

int main()

{ int num1 = 1; int num2 = 2; int total = 0; std::cout << "total = " << total << std::endl; total = addition(num1, num2); std::cout << "After addition(num1, num2), total = " << total << std::endl; }

int addition (int a, int b) { int r; r = a + b; return r; }

a) Because variable a is not defined in the body of the even and odd functions.
b) Because the function call does not match the function definition.
c) Because the function is not declared prior to the function call. Their prototype is needed above main.
d) Because the variable i is not initialized to a valid integer value before it is used.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!