/* This is the tenth lab of Lab EE107
The purpose of this lab for finding out the greatest common
divisor via calling a function.
Creating the code and free of syntax and grammatical errors.
Author: Ekwegbalum Unachukwu
Star ID:do2170dt
Date: April 2nd, 2024.
*/
#include <stdio.h>
// Function to calculate the greatest common divisor (GCD)
int calculateGCD_EU(int a_EU, int b_EU) {
int temp_EU;
while (b_EU != 0) {
temp_EU = b_EU;
b_EU = a_EU % b_EU;
a_EU = temp_EU;
}
return a_EU;
}
int main() {
int num1_EU, num2_EU;
// Input two numbers
printf("Enter two numbers to find their greatest common divisor (GCD):\n");
printf("Number 1: ");
scanf("%d", &num1_EU);
printf("%i\n",num1_EU);
printf("Number 2: ");
scanf("%d", &num2_EU);
printf("%i\n",num2_EU);
// Calculate GCD
int gcd_EU = calculateGCD_EU(num1_EU, num2_EU);
// Display the result
printf("The greatest common divisor (GCD) of %d and %d is: %d\n", num1_EU, num2_EU, gcd_EU);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: