C Program to find the GCD of the given two numbers using Iteration..


#include<stdio.h>
int gcd(int a,int b)
{
 int t;
 while(b!=0)
 {
 t=b;
 b=a%b;
 a=t;
 }
 return a;
}

void main()
{
 int x,y;
 printf("Enter any two numbers..");
 scanf("%d%d",&x,&y);
 printf("\nThe gcd of the given two number is..%d",gcd(x,y));
}

No comments:

Post a comment