Hello All,
I am tasked with creating an integer file from 0 - 100. I am to make every 10th integer to be a random number.
i.e.
Code:
0
1
2
3
4
5
6
7
8
9
25
11
12
13
14
.
.
.
I realize that is actually the 11th digit starting from 0. I have enclosed my code.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i, ran;
FILE *fp;
fp = fopen("100_semi.txt", "w+");
for (i = 0; i < 100; i++){
if (i/10) {
ran = rand() % 100;
fprintf(fp, "%d\n", ran);
//fprintf(fp, "%d\n", i);
}
else fprintf (fp, "%d\n", i);
}
//fprintf(fp, "%d\n", i);
return 0;
}
My output as of right now is:
Code:
0
1
2
3
4
5
6
7
8
9
41
67
34
0
69
24
78
58
62
64
5
I am hoping someone can tell me what I need to do to correct my problem.
I truely appreciate it.