Page

C program for finding the GCD

#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],c,m,n,r,i,g;
int b=100;
c=b;
clrscr();
printf("\n Enter the Number of Array : ");
scanf("%d",&m);
for(i=1;i<=m;i++)
{
printf("\n\n");
printf("\n Enter the value : ");
scanf("%d",&a[i]);
while(b!=0)
{
n=a[i]/b;
r=a[i]%b;
a[i]=n*b+r;
a[i]=b;
b=r;
}
b=c;
printf("\n\n GCD is : %d",a[i]);
}
getch();
}

No comments:

Post a Comment