I made this program (using C not C++):
Code:
#include<stdio.h>
int num1, num2;
int main() {
printf("Type in two numbers: ");
scanf("%d %d", &num1, &num2);
while (num1!=num2){
if (num1>num2){
num1=num1-num2;
} else {
num2=num2-num1;
}
}
printf("The GCD is: \n%d");
}
but it's not working correctly. I'm suppose to use 2 integers and like 21 and 15 and then I have to get the GCD, and the GCD should be 3 out of 21 and 15 but in my programme it display 2293624 for any 2 numbers.
Can someone please explain what did I do wrong and how can I fix it
Thanks