Tuesday, June 25, 2013

Write Program to find Highest common factor (HFC) of two no ?

Problem :
 Find Greatest Common divisor for given two no, ex 22 and 33 HFC is 11

Solution:

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

void main()
{
int no1,no2,temp;
clrscr();
printf("\n enter the two no decesending order ");
scanf("%d%d",&no1,&no2);
while(no2!=0)
{
 temp=no1%no2;
 no1=no2;
 no2=temp;
}
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