This is what i got so far, i hope you can understand my code i don't know if its near right, I'm new at this, this is like my third code.
C program that reads an odd number between 1 and 19 from user and then displays a diamond with that many rows as below.
Your printf statements should print a single *, +, - or blank. So maximize your use of nested loops while minimizing printf statemens.
Odd numbered rows should be drawn by *, even numbered rows should be drawn by +, while the middle raw is drawn by -.
Suppose user enters number as 9, then your program should display the following diamond.
*
+++
*****
+++++++
---------
+++++++
*****
+++
*
Code:#include<stdio.h> #include<math.h> int main() { int i, j; printf("Enter a Number between 1-19 n\") scanf("%d", &number); for(i=1; i <= 19; i++) { printf("i=%d ", i); for(j=1; j <= i; j++) { if (i % 2 == 0) printf("+ "); else printf("* "); } printf("\n"); } return 0; }



LinkBack URL
About LinkBacks



