Question

C++ Write code using 2 nested loops, that produces the following output.

Write code using 2 nested loops, that produces the following output. 1 5 4 3 2 1 4 3 2 1 3 2 1 code.cpp New #include <iostrea

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

#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=i;j>=1;j--)
   {
       cout<<j<<" ";
   }
   cout<<"\n";
}
return 0;
}

Output:

Enter number of rows: 5 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1

Add a comment
Know the answer?
Add Answer to:
C++ Write code using 2 nested loops, that produces the following output. Write code using 2...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT