Write a definition for a void function that has three arguments of type int and
ID: 3566939 • Letter: W
Question
Write a definition for a void function that has three arguments of type int and outputs to the screen the product of these three arguments. Put the definition in a complete program that reads in three numbers and then calls this function.
Here are the detail steps:
Declare and define a void function to read three integers and output them to the screen.
Define three integer variables
Prompt user to enter three integer values
Use cin to read entered values
Call defined function.
Debug your code
Modify your code for programming styles
The output of your code might be similar to this :
Enter three whole numbers: 0 -11 45
The entered numbers are 0 , -11 ,and 45
The product of above three numbers is 0
Explanation / Answer
#include<iostream>
using namespace std;
void product(int x, int y, int z){
cout << "The product of above three numbers is " << x*y*z << endl;
}
int main(){
int x,y,z;
cout << "Enter three whole numbers: ";
cin >> x;
cin >> y;
cin >> z;
cout << "The entered numbers are " << x << ", " << y << ",and " << z << endl;
product(x, y, z);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.