So I'm taking an OpenSource C class and I literally cannot think my way through a problem. I need to get a number from a user (example: 4), and then use that number to create
xx
xxx
xxxx
xxxxx
with the number as the base. Here's what I know so far: I need to create a nested loop (two for statements).
Here's what I have so far:
I've been trying for hours and I have no idea how to tackle and defeat this nested loop. Any ideas? Thank you.Code:#include <cs50.h> #include <stdio.h> int main(void) { printf("Insert a non-negative integer no greater than 23: "); int x = GetInt(); while (x > 23 || x < 0) { printf("Insert a non-negative integer less than 24!: "); x = GetInt(); } return 0; } // here's the nested loop part int row; for (row = 1; row == (x - 1); row++); { int c; for (c = 1; c == (x - 1); c++) printf(" "); int z; for (z =2; z == (row + 1); row++) printf("#"); } return 0; }



LinkBack URL
About LinkBacks



