First, your code is not complete. I assume that it look like this:
Code:
#include <stdio.h>
int main (void) {
int spoj1min = 17;
int spoj2min = 12;
int x = 0;
while(x != 7) {
x = spoj1min % spoj2min;
spoj1min = spoj1min + spoj1min;
printf("%d\n", spoj1min);
}
return 0;
}
The problem is in this line:
Code:
spoj1min = spoj1min + spoj1min;
This will double the value of spoj1min in every iteration and this will result in an overflow.
You can check this with an emergency break:
Code:
#include <stdio.h>
int main (void) {
int spoj1min = 17;
int spoj2min = 12;
int x = 0;
int em_brk = 0;
while(x != 7) {
x = spoj1min % spoj2min;
spoj1min = spoj1min + spoj1min;
printf("%d\n", spoj1min);
if (++em_brk > 50) break;
}
return 0;
}
The program will stop and you can scroll up and see was happens.
I think you want increase spoj1min by 17 in every iteration.
The best way is to assing a new variable (call it 'add_on') and give it the value (in your case: 17).
In the loop add 'add_on' to 'spoj1min' in every iteration.
Then calculate the reminder, print booth out and finish.
If the reminder (x) is 7, the loop will stop.
Leave the emergency break in plaece. It could be that you give numbers that never fulfilled the break contion of the loop.