Write a program in C++ to print the following pattern:
5
5 4
5 4 3
5 4 3 2
5 4 3 2 1
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int n=5;
cout<<"Enter n: ";
cin>>n;
int k=n;
for(int i=0;i<n;i++){
for(int j=n;j>=k;j--){
cout<<j<<" ";
}
k-=1;
cout<<"\n";
}
system("pause");
return 0;
}
Comments
Leave a comment