I just made code that calculates the multiplication tables, based on user input. The problem is that after I print the results, the program closes and I need to relaunch it to get different input and results.
I want to get the results and press a key to get a new value from the user: I don't want to be constantly closing and opening the the program. How can I do this?
This is my code:
#include <iostream>
using namespace std;
int main()
{
int a, range;
cout << "Introduce value: ";
cin >> a;
printf("\n");
cout << "Introduce range: ";
cin >> range;
printf("\n");
for (int i = 1; i <= range; ++i)
{
cout << a << " * " << i << " = " << a*i << endl;
}
printf("\n");
system("pause");
}