# every 10th number to be random

This is a discussion on every 10th number to be random within the C Programming forums, part of the General Programming Boards category; Hello All, I am tasked with creating an integer file from 0 - 100. I am to make every 10th ...

1. ## every 10th number to be random

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.

2. I think this is what you are looking for
Code:
```if ((i+1)%10 == 0) {
/* random*/
}```
I think we should use the module for this kind of operations

3. Originally Posted by std10093
I think this is what you are looking for
Code:
```if ((i+1)%10 == 0) {
/* random*/
}```
I think we should use the module for this kind of operations