How to create a program that generates a reverse triangle bearing the numbers of the multiplication table on the user's encoded number. + The user will input any positive whole number that should be greater than 1 and not be greater than 40. If the input is outside the range display "INVALID".
sample input: 5
Sample Output :
1.2.3.4.5
2.4.6.8
3.6.9
4.8
5
Sample Input :10
Sample Output :
01.02.03.04.05.06.07.08.09.10
02.04.06.08.10.12.14.16.18
03.06.09.12.15.18.21.24
04.08.12.16.20.24.28
05.10.15.20.25.30
06.12.18.24.30
07.14.21.28
08.16.24
09.18
10
#include<iostream>
#include<conio.h>
using namespace std;
int main(){
int n,cols;
cout<<"Enter the number of rows: ";
cin>>n;
int num=0;
while(n>=0){
cols=0;
num+=1;
while(cols<n){
cout<<(cols+1)*(num)<<"\t";
cols+=1;
}
n-=1;
cout<<"\n";
}
}
Comments
Leave a comment