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
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 . ...
Comments
Post a Comment