#include(stdio.h) // Note place '<' & '>' in place of '(' & ')'
int gcd(int,int);
void main()
{
int a[10],n,i,b[10];
int x,y;
clrscr();
printf("Enter the size of the array:");
scanf("%d",&n);
printf("\nEnter the array elements:");
for(i=0; i< n ;i++)
scanf("%d",&a[i]);
int gcd(int,int);
void main()
{
int a[10],n,i,b[10];
int x,y;
clrscr();
printf("Enter the size of the array:");
scanf("%d",&n);
printf("\nEnter the array elements:");
for(i=0; i< n ;i++)
scanf("%d",&a[i]);
for(i=0; i< n-1 ;i++)
{
x=a[i];
y=a[i+1];
b[i]=gcd(x,y);
printf("\nG.C.D of %d and %d is : %d",x,y,b[i]);
}
{
x=a[i];
y=a[i+1];
b[i]=gcd(x,y);
printf("\nG.C.D of %d and %d is : %d",x,y,b[i]);
}
getch();
}
int gcd(int a,int b)
{
int rem;
for(;;)
{
rem=a%b;
if(rem==0)
break;
a=b;
b=rem;
}
return b;
}
}
int gcd(int a,int b)
{
int rem;
for(;;)
{
rem=a%b;
if(rem==0)
break;
a=b;
b=rem;
}
return b;
}
No comments:
Post a Comment