Write a program to find the table of numbers using a while loop. Your program should ask the
size of the table. That size defines the rows and columns. Sample output:
Enter size: 6
1 2 3 4 5 6
------------------------------------------
1* 1 2 3 4 5 6
2* 2 4 6 8 10 12
3* 3 6 9 12 15 18
4* 4 8 12 16 20 24
5* 5 10 15 20 25 30
6* 6 12 18 24 30 36
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter size: ";
cin >> n;
for (int i=1; i<=n; i++) {
cout << i << " ";
}
cout << endl;
cout << "------------------------------------------" << endl;
for (int i=1; i<=6; i++) {
cout << i << "* ";
for (int j=1; j<=6; j++) {
cout << i*j << " ";
}
cout << endl;
}
return 0;
}
Comments
Leave a comment