Answer to Question #320624 in C++ for nickname

Question #320624

Look at the following code and identify what is wrong with it:

 

void multiply(int, int);

 

int main() {

  std::cout << "The answer is: " << multiply(num1, num2);

}

 

void multiply(int a, int b) {

  return a * b;

}

 

Prototype is missing variable names.

Int parameters should be doubles.

Void functions cannot return a value.

Value-returning functions must be called in a statement that stores the returned value in a variable.


1
Expert's answer
2022-04-01T08:43:59-0400
Void functions cannot return a value.

#include <iostream>

int multiply(int, int); 


int main() {

int num1=3, num2=5;

 std::cout << "The answer is: " << multiply(num1, num2);

}


int multiply(int a, int b) { 

 return a * b;

}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog