0

Program by while fn

* ** *** **** ***** ******

21st Nov 2019, 8:10 AM
Asif Nawaz
Asif Nawaz - avatar
9 Antworten
+ 1
hope this will help #include<stdio.h> int main() { int i,j,n; printf("Enter how many rows you want: \n"); scanf("%d",&n); i=1; while(i<=n) { j=1; while(j<= n-i){ printf(" "); j++;} j=1; while(j<=i){ printf("*"); j++;}printf("\n"); i++;} return 0; }
21st Nov 2019, 9:31 AM
heba fadhil
heba fadhil - avatar
0
what is your problem?
21st Nov 2019, 8:55 AM
heba fadhil
heba fadhil - avatar
0
I want to print above pattern using while
21st Nov 2019, 8:57 AM
Asif Nawaz
Asif Nawaz - avatar
0
Thank you If you ans it for Python It will be more helpful for me There are 5 lines
21st Nov 2019, 9:34 AM
Asif Nawaz
Asif Nawaz - avatar
0
This is the python code num = int(input("Enter the range: \t \n")) # i loop for range(height) of the triangle # first j loop for printing space ' ' # second j loop for printing stars '*' i=0 while i <(num): j=0 while j <((num - i) - 1): print(end=" ") j=j+1 j=0 while j <(i + 1): print("*", end=" ") j=j+1 i=i+1 print()
21st Nov 2019, 11:16 AM
heba fadhil
heba fadhil - avatar
0
No. I want to print in the form if equilateral triangle in this ∆ form
21st Nov 2019, 11:35 AM
Asif Nawaz
Asif Nawaz - avatar
0
i=1 while i<=5: j=1 while j<=5-i: print(" ",end="") j=j+1 j=1 while j<=i*2: print("*",end="") j=j+1 i=i+1 print()
21st Nov 2019, 11:44 AM
Asif Nawaz
Asif Nawaz - avatar
0
But i unable to print 1st one
21st Nov 2019, 11:45 AM
Asif Nawaz
Asif Nawaz - avatar
0
it print any number you want. i am sure it work.
21st Nov 2019, 1:15 PM
heba fadhil
heba fadhil - avatar