print pattern 12345 , 23451, 34512 ,45123 ,51234 in c++ and python

12345
23451
34512
45123
51234

How to print this pattern in c++?



CODE:
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ int i=1,k,j;
  while(i<=5)
  { j=i;
    while(j<=5)
    {
        cout<<j;
        j++;
    }
    k=1;
    while(k<i)
    {
        cout<<k;
        k++;
    }
    cout<<endl;
    i++;
  }
}



OUTPUT:



How to print this pattern in python?


CODE:

i=1
while(i<=5):
    j=i
    while(j<=5):
        print(j,sep="",end="")
        j=j+1
    k=1
    while(k<i):
        print(k,sep="",end="")
        k=k+1
    print()
    i+=1


OUTPUT:






NOTE: Make sure you have properly indented the python code.Proper indentation of python code is very much important


Comments

Popular posts from this blog

CODE to print rhombus in python

printing triangle pattern using for loops in c++

CODE to Print a square(hollow) in python