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