Write a program that takes three composite Nonprime positive
Write a program that takes three composite (Non-prime) positive integers from the user and computes their greatest common divisor (gcd).
Solution
#include <stdio.h> // header files
int gcd(int a, int b){ // function to find gcd of 2 numbers
while (a %= b){ // checking gcd condition
int s = a; // if yes returning it
a = b;
b = s;
}
return b;
}
main(){ //main function
int a = 100, b = 60, c = 12; // takeing input values
int gd = gcd(gcd(a, b), c);
printf(\"%d\",gd);
getch();
}
OUTPUT:
4
