I wrote a simple C program to print all the multiples of 3 but there is some error during runtime my code is:
#include <stdio.h>
void main(void) {
int i, x;
for(i = 1; i < 1000; i++) {
x = i % 3;
if(x == 0) {
printf("%d\n", i);
}
}
}
the problem is that if I enter numbers greater than 891 till 1000 in the loop the output is starting from 6 instead of 3 and if i write the code as above than the output is starting from 114. for the values less than or equal to 891 it is showing the correct output.