Looping Program

Looping program

Use a while loop to make a program that takes an input and outputs every multiplication of the input from 0 to 20.

Example

3
3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
...
3 x 18 = 54
3 x 19 = 57
3 x 20 = 60

Answer

#include <iostream>

int main() 
{
	std::cout << "Input a number to view it's multiplication table.\n";

	float input;
	std::cin >> input;

	int counter = 1;
	while (counter <= 20)
	{
		std::cout << "3 x " << counter << " = " << 3*counter << "\n";
		counter++;
	}
}
Questions