C programming

Tuesday, January 13, 2009

#include #include int gcd(int x,int y) { int small,large; small=x; large=y; if(x>y) { small=y;large=x; } while(large%small!=0) { int c=large%small; large=small; small=c; } return small; } void main() { clrscr(); int d,n,num[50],i,value,j; printf("How many number you want to enter:"); scanf("%d",&n); for(i=0;i { printf("Number[%d]=",i+1); scanf("%d",&num[i]); } d=num[0]; for(i=1;i { d=gcd(d,num[i]); for(j=i+1;j { if(num[j]%d==0) { value=1; continue; } else { value=0; break; } } if(value==1) break; } printf("The gcd = %d",d); getch(); }

0 comments:

Visitors

PlugIn.ws - Free Hit Counter, Web Site Statistics, Traffic Analysis

  © Blogger template Leaving by Ourblogtemplates.com 2008

Back to TOP