/*Serial No.161 [swami20.cpp]*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,hcf,a1,b1;
clrscr();
printf("Enter the first number==>");
scanf("%d",&a1);
printf("Enter the second number==>");
scanf("%d",&b1);
a=a1;
b=b1;
if(a==0&&b==0)
printf("You can not enter 0");
else
while(a!=b)
{
if(a>b)
a=a-b;
else
b=b-a;
}
hcf=a;
printf("The gcd of %d , %d is==> %d",a1,b1,hcf);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,hcf,a1,b1;
clrscr();
printf("Enter the first number==>");
scanf("%d",&a1);
printf("Enter the second number==>");
scanf("%d",&b1);
a=a1;
b=b1;
if(a==0&&b==0)
printf("You can not enter 0");
else
while(a!=b)
{
if(a>b)
a=a-b;
else
b=b-a;
}
hcf=a;
printf("The gcd of %d , %d is==> %d",a1,b1,hcf);
getch();
}
No comments:
Post a Comment
If you have any doubt, feel free to ask...