Answer to Question #299785 in C++ for Nancy

Question #299785

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

1
Expert's answer
2022-02-20T14:41:00-0500


#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog