for C++
Write a function containing a while loop that lets the user enter a number. The number should be multiplied by 10, and the result stored in the variable product . The loop should iterate as long as product contains a value less than 100. Have the function return product.
#include <iostream> using namespace std; int get_product() { int number, product = 0; while (product < 100) { cout << "Enter a number: "; cin >> number; product = number * 10; } return product; } int main() { cout << "Product is " << get_product() << endl; return 0; }
Get Answers For Free
Most questions answered within 1 hours.