I have this simple problem:
# include <stdio.h>
int main(){
unsigned a, b, x, y, temp;
a=100;
b=30;
x=a*b;
printf("%u", x);
while(b) temp=a%b, a=b, b=temp; // try to comment this line
y=b;
x/=y;
printf("%u", x);
return 0;
}
If I put this code into main.c it returns "Program finished with exit code 0", and there will be no printf
, else if I comment the while loop I will get the printf
s.
Can you explain why the while
loop influences the program this way?
What actually I should achieve with this problem is the division by 0 at the final line x/=y;
.