Questions:
Right Triangle pattern using numerical digits
Code:
#include<iostream>
using namespace std;
void main()
{
//Right Triangle pattern using numerical digits
//5 4 3 2 1
//5 4 3 2
//5 4 3
//5 4
//5
int square;
cout<<"Enter The Size of Square = "; // size
cin>>square;
for(int i = 1;i<=square;i++) // outer loop
{
for(int j=square;j>=i;j--) //inner loop
{
cout<<j<<" "; // value that is output
}
cout<<endl;//new line for next line output
}
}
Output
Right Triangle pattern using numerical digits
Code:
#include<iostream>
using namespace std;
void main()
{
//Right Triangle pattern using numerical digits
//5 4 3 2 1
//5 4 3 2
//5 4 3
//5 4
//5
int square;
cout<<"Enter The Size of Square = "; // size
cin>>square;
for(int i = 1;i<=square;i++) // outer loop
{
for(int j=square;j>=i;j--) //inner loop
{
cout<<j<<" "; // value that is output
}
cout<<endl;//new line for next line output
}
}
Output
0 Questions:
Post a Comment