![]() |
star pattern
Q: Genrate star pattern below
Code:
* *Code:
main() Code:
* *if i put "j<=2" in last for loop check condition then this extra star moves in first row like this O/P: Code:
* * * |
star pattern1
Q: Genrate star pattern below like crown
total 3 rows , and 5 columns, 5stars in 3rd row , 2stars on right and 2stars on left side i.e total 4 stars in 2nd row, 1star on right and 1 star on left side i.e. total 2 stars in 1 st row, * * * * * * * * * * * __________________________________________________ Program: Coding: main() { int a=3,i,j; char k='*'; clrscr(); for(i=1;i<=3;i++) { for(j=1;j<=i;j++ ) printf("%3c",k); for(j=1;j<=a;j++) printf(" "); a-=2; for(j=1;j<=i;j++) printf("%3c",k); printf("\n"); } getch(); } O/P: * * * * * * * * * * * * This is the o/p i m getting what should be done to remove this one extra star in last line. if i put "j<=2" in last for loop check condition then this extra star moves in first row like this O/P: * * * * * * * * * * * * so plz suggest right solution to get desired o/p. [/quote] |
Re: star pattern
Code Blocks you should use.
|
| All times are GMT +5.5. The time now is 23:52. |