C program for the following pattern | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

C program for the following pattern

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

8th Jul 2020, 3:53 AM
Suman Singh
Suman Singh - avatar
7 Answers
+ 7
Your conditions are not working properly first do dry run then make logics
8th Jul 2020, 6:23 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
8th Jul 2020, 3:58 AM
Shino
Shino - avatar
+ 3
Your code was pretty close #include <stdio.h> int main() { int k=0; for(int i=1;i<=9;i++) { (i<6)?k++:k--; for(int j=1;j<=9;j++) { if((j<=5-k||j>=5+k) && i!=5) printf("*"); else printf(" "); } printf("\n"); } return 0; }
8th Jul 2020, 4:44 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
#include <stdio.h> int main() { int k=0; for(int i=1;i<=7;i++) { (i<=3&&(!(i==4)))?k++:k--; for(int j=1;j<=7;j++) { if(((j<=4-k||j>=4+k))&&(i!=4)) printf("*"); else printf(" "); } printf("\n"); } return 0; }
8th Jul 2020, 4:04 AM
Suman Singh
Suman Singh - avatar
+ 1
There is no stars in full Row 5 and full column 5
8th Jul 2020, 4:36 AM
Suman Singh
Suman Singh - avatar
0
Thnx
8th Jul 2020, 6:46 PM
Suman Singh
Suman Singh - avatar
- 1
Hi
8th Jul 2020, 12:48 PM
Amam Baks
Amam Baks - avatar