Close sidebar

1 2 3 2 3 4 5 4 3 4 5 6 7 6 5 4 5 6 7 8 9 8 7 6 5

I am trying to do this program but not able to get output can anyone help me

  • Manam
  • 1476 Views
  • 9 Answers
  • Use do while loop.


  • Hi Harish,br /Use this code it will work...to get more understand on the logic i kept more spaces..if you don't want u can comment those statements.br /br //*br /Program : Pattern Program of printing... 1 2 3 2 3 4 5 4 3 4 5 6 7 6 5 4 5 6 7 8 9 8 7 6 5br /Author : Rajanikanthbr /Language: C++br /Email : rnvrk.2015@gmail.combr /*/br /br /#include<iostream>br /using namespace std;br ///1     2 3 2    3 4 5 4 3    4 5 6 7 6 5 4    5 6 7 8 9 8 7 6 5br /int main()br /{br /int num, noft; //number of timesbr /int rep=0; //repetitionbr /cout<<"How many times you want to repeat this pattern...";br /cin>>noft;br /for(int cnt=1; cnt<=noft; cnt++)br /{br /for(num=cnt; num<=cnt+rep; num++)br /cout<<num<<" ";br /for(num=num-2; num>=cnt; num--)br /cout<<num<<" ";br /cout<<"  ";br /rep++;br /}br /}


  • Use do while so you can get like this output

    -1

  • Use do while loop

    -1

  • Do you require the above pattern? 

    -1

  • Is this a pattern printing program?? Do u require this kind of single line output?

    -1

  • can you share ur code..? br /After reviewing I will give the solution

    -1

Dicussion/Forum
core java
Ask New Question
Community Moderator
Only Youth and Educator can become Moderator.