This is the line of code I have as a foundation of what I need to do.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <time.h>
4 #include <unistd.h>
5
6
7
8 int main() {
9
10 int num;
11 float test;
12 printf("Hello World\n");
13
14 srand(time(NULL));
15
16 for(int x = 0; x<10; x++){
17 //generate number here:
18 // num = (rand() % (higher - lower + 1)) + lower;
19 num = (rand() % (25-13 +1)) + 13;
20
21 printf("Number is %d\n", num);
22 usleep(100000);
23 }
24 const int numRows = 6;
25 const int numCols = 21;
26 for (int row = 0; row < numRows; ++row)
27 {
28 for (int col = 0; col < numCols; ++col)
29 {
30 if (col == row)
31 {
32 printf("X");
33 }
34 else
35 {
36 printf(" ");
37 }
38 }
39 printf("\n");
40 }
41
42
43
44 return 0;
45 }
This is the desired out come i'd like :
Instead of the "*" is it possible to input randomly generated numbers? Im required to include the sleep function and randomly generated numbers but i'm stuck on how to make the vertical zig zag.
Does anyone have any pointers/ solutions?
I created code to generate random numbers and used the sleep function. I also began a zig zag pattern but having difficulty to continue it vertically.