Plz tell me a program to display the following pattern. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Plz tell me a program to display the following pattern.

1 2 3 4 5 1 2 3 4 1 2 3 1 2 1

7th Dec 2016, 4:44 PM
Shubhangi Ovhal
Shubhangi Ovhal - avatar
2 Answers
+ 3
#include <iostream> using namespace std; int main() { for(int i=0;i<5;i++){ int x=1; for(int j=0;j<5;j++) { if(j<i){ cout <<" "; }else{ cout <<x++<<" "; } } cout<<endl; } return 0; }
7th Dec 2016, 5:35 PM
Saeed
Saeed - avatar
+ 1
Code::Blocks
7th Dec 2016, 5:19 PM
Pranav Parab
Pranav Parab - avatar