Program find GCD Example Code in C C++ with Loop
#include<stdio.h>
#include<conio.h>
int gcd(int,int);
void main()
{
clrscr();
int num1,num2;
printf("enter the numbers\n");
scanf("%d%d",&num1,&num2);
printf("the gcd is=%d",gcd (num1,num2));
getch();
}
int gcd(int a,int b)
{
int i,h,k;
if(a<b)
h=a;
else
h=b;
for(i=1;i<=h;i++)
{
if(a%i==0 && b%i==0)
k=i;
}
return(k);
}
0 comments:
Post a Comment