写一个程序满足以下要求a) Document that a program calculates the product of three integers. b) Declare the variables x, y, z and result to be of type int (in separate statements) and initialize each to 0. c) Prompt the user to enter three integers. d) Read three integers from the keyboard and store them in the variables x, y and z. e) Compute the product of the three integers contained in variables x, y and z, and assign the result to the variable result. f) Print "The product is " followed by the value of the variable result. g) Return a value from main indicating that the program terminated successfully.
时间: 2024-02-17 22:00:23 浏览: 81
下面是满足要求的C++程序:
```cpp
// This program calculates the product of three integers.
#include <iostream>
int main() {
// Declare variables and initialize them to 0.
int x = 0;
int y = 0;
int z = 0;
int result = 0;
// Prompt the user to enter three integers.
std::cout << "Please enter three integers: ";
// Read three integers from the keyboard and store them in the variables x, y and z.
std::cin >> x >> y >> z;
// Compute the product of the three integers contained in variables x, y and z, and assign the result to the variable result.
result = x * y * z;
// Print "The product is " followed by the value of the variable result.
std::cout << "The product is " << result << std::endl;
// Return a value from main indicating that the program terminated successfully.
return 0;
}
```
阅读全文