[圖解C] Example 804: using function with no parameters

// Example 804: using function with no parameters

#include <stdio.h>
#include <stdlib.h>

// no parameters input
int find_GCD();

int main()
{
    int GCD;
   
    GCD = find_GCD();
    printf("GCD = %d\n", GCD);
   
    system("pause");
    return 0;  
}


int find_GCD()
{
    int v1, v2, temp;
   
    printf("enter the integer v1: ");
    scanf("%d", &v1);
    printf("enter the integer v2: ");
    scanf("%d", &v2);
   
    while (v2 != 0){
        temp = v1 % v2;
        v1 = v2;
        v2 = temp;
    }
   
    return v1;
}