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
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
No comments:
Post a Comment