Triangle angle triangle pattern
You must aware of basic concept of loop.
#include <iostream>
using namespace std;
int main() {
int a,b,s,row=5;
//this loop will print new line
for(a=1;a<=row;a++){
//this loop will print space required in line
for(s=a;s<=row;s++){
cout<<" ";
}
//this loop print the number
for(b=a;b>=1;b--){
cout<<b;
}
cout<<endl;
}
return 0;
}
using namespace std;
int main() {
int a,b,s,row=5;
//this loop will print new line
for(a=1;a<=row;a++){
//this loop will print space required in line
for(s=a;s<=row;s++){
cout<<" ";
}
//this loop print the number
for(b=a;b>=1;b--){
cout<<b;
}
cout<<endl;
}
return 0;
}
No comments:
Post a Comment