Posts

12345 23455 34555 45555 55555 i=1 k=5 while(i<=5):     j=i     while(j<=5):         print(j,sep="",end="")         j=j+1     m=1     k=5     while(m<i):         print(k,sep="",end="")         m=m+1     i=i+1     print()    

CODE to print rhombus in python

Image
How to print rhombus in python ? code: n=int(input("enter size of rhombus")) i=1 k=n while(i<=n):        #this loop will print n numbers of rows     while(k>=1):    #this loop is used to gave spaces         print(" "*k,end="") #this line will print k number of spaces         print("*"*n)      #this line will print n number of asterix symbol         k=k-1     i=i+1 output: THANKYOU    

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

Image
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 O...

CODE to Print a square(hollow) in python

Image
Print a square(hollow) in python n=int(input("enter any number")) i=1 while(i<=n):     if(i==1 or i==n):         print("*"*n)             else:          print("*",end="")          print(" "*(n-2),end="")          print("*")             i+=1 OUTPUT : THANKYOU

print letter T using for loop in c++ language

Image
Write a program that reads in a number and prints out the letter T using '*' characters with each line in the T having width n.  Further, the length of the horizontal bar should be 3n, and that of the vertical bar 2n.   #include<iostream> using namespace std; int main() {  //Double slash is used to give comment in c++ language.    long i,j,k,n,x,z;   cout<<"enter the value of n: ";   cin>>n;   for(i=0;i<n;i++)          //this loop is used to print n number of  rows   {      for(j=0;j<3*n;j++)    //this loop is used to print 3*n number of columns     {cout<<"*";}    cout<<endl;                //endl moves the cursor to next line.   }   for(k=0;k<2*n;k++)    //this loop is used to print 2* n number of  rows   {   ...

printing triangle pattern using for loops in c++

Image
                                  C ode to print triangle in c++ #include<iostream> using namespace std; int main() { //Double slash is used to give comment in c++ language. int i,j,k; for(i=0;i<7;i=i+1) {     for(k=20-i;k>=0;k--)  //loop for spacing      {cout<<" ";}     for(j=0;j<=i;j++)      {cout<<"* ";}          //don't forget to give one space after * cout<<endl;                  //endl move the cursor to next line } return(0); } OUTPUT: NOTE: In the above code i used k=20-i, you can use any number in place of 20 but the number should be more than the total number of asterisk(*) present in the last line of triangle  pattern .              ...