Tuesday, June 25, 2013

Write a Program to find high common factor (HFC) three no ?

Problem :
 Find Greatest Common divisor for given three no, ex125,25 and 15 HFC is 5

Solution:

#include<stdio.h>
#include<conio.h>

void main()
{
int no1,no2,no3,temp,flag=0;
clrscr();
printf("\n enter the two no decesending order ");
scanf("%d%d%d",&no1,&no2,&no3);
start:
while(no2!=0)
{
 temp=no1%no2;
 no1=no2;
 no2=temp;
}
if(flag==0)
{
flag=1;
if(no1<no3)
{
no1=no3;
no2=no1;
}
else
{
no1
goto start;
}
printf("\n the highest comman factor is %d",no1);
getch();
}


Output:








if any doubt, post it on comment

Like the Post? Do share with your Friends.

No comments:

Post a Comment