Well, I've been having problems with compilation on Ubuntu's Codeblocks in release mode. In Debug, as in other IDEs, the output value goes out correctly, but in the release mode it goes like this:
The code is the simple Euclid algorithm to calculate the greatest common divisor (mdc):
#include <stdio.h>
#include <stdlib.h>
int main()
{
int maioref, menoref, maior, menor, resto, mdc;
printf("Digite o módulo do maior valor para calcular o mdc:\n");
scanf("%d", &maioref);
printf("Digite o módulo do menor valor para calcular o mdc:\n");
scanf("%d", &menoref);
maior=maioref;
menor=menoref;
while(resto!=0)
{
resto=maior%menor;
maior=menor;
menor=resto;
}
mdc=maior;
printf("O Mdc entre %d e %d é: %d", maioref, menoref, mdc);
return 0;
}
The output in the release mode with the values (24;15):
Enter the modulus of the highest value to calculate the mdc:
24
Enter the modulus of the smallest value to calculate the mdc:
15
The Mdc between 24 and 15 is 24
The output in the debug mode with the values (24;15):
Enter the modulus of the highest value to calculate the mdc:
24
Enter the modulus of the smallest value to calculate the mdc:
15
The Mdc between 24 and 15 is 3
What is wrong? (obs: sorry for bad english)