‘C’ program to calculate the GCD of two numbers.
C File =>
/* Write a ‘C’ program to calculate the GCD of two numbers. */
#include<stdio.h>
int main()
{
int m, n;
printf("Enter two positive integers: ");
scanf("%d %d",&m,&n);
while(m!=n)
{
if(m > n)
m = m - n;
else
n = n - m;
}
printf("GCD = %d",m);
return 0;
}
Comments
Post a Comment
Please do not enter any spam link in message.