Program to find the GCD of three numbers in C
In this program, I have discussed about how to find the GCD of three numbers in C.
#include<stdio.h>int main()
{ int a,b,c,d,hcf=0,i;
printf("Enter three numbers: \n");
scanf("%d%d%d",&a,&b,&c);
for(i=1;i<=a;i++)
{
if(a%i==0&&b%i==0&c%i==0)
{
if(i>hcf)
{hcf=i;
}
}
}
printf("HCF is %d ",hcf);
}
Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.
Enjoy programming in C.
0 comments:
Post a Comment