- To print half opposite reverse triangle pattern using *
User Input: 4
Output:
* * * * * * * * * *
#include <iostream>
using namespace std;
int main() {
int rows;
cout<<"Enter number of rows : ";
cin>>rows;
for(int i=rows; i>=1; i--) {
for(int j=1; j<=rows; j++) {
if(j<i)cout<<" ";
else cout<<"* ";
}
cout<<endl;
}
return 0;
}
Enter number of rows : 4 * * * * * * * * * *Program
Main logic :
for(int i=rows; i>=1; i--) { //rows : number of rows to print
for(int j=1; j<=rows; j++) {
if(j<i)cout<<" ";
else cout<<"* ";
}
cout<<endl;
}
You can print any thing in this pattern, just replace your value with *
Coming Soon !
QuickIf your happiness depends on what somebody else does, I guess you do have a problem.