
Answers:
Source: CoolInterview.com
Take 4 numbers.The smallest number has to be found out.Then divide each number by that numbers which are less than that smallest number. e.g.5,15,75,20 smallest5 so divide each numbers by 1,2,3,4,5. The GCD will be that number which divides all the number.(here 5) Source: CoolInterview.com
Posted by: prasenjit
Contact prasenjit
Source: CoolInterview.com
Global coding data Source: CoolInterview.com
Posted by: saumya
Contact saumya
Source: CoolInterview.com
#include<stdio.h> void main() { int a,b,c,d,i,gcd; printf("Enter Number 1"); scanf("%d",a); printf("Enter Number 2"); scanf("%d",b); printf("Enter Number 3"); scanf("%d",c); printf("Enter Number 4"); scanf("%d",d); for(i=1;i++;) { if((n%a==0)&&(n%b==0)&&(n%c==0)&&(n%d==0) {break;} ) lcm = ((a*b*c*d)/i); }
Source: CoolInterview.com
Posted by: Aj
Contact Aj
Source: CoolInterview.com
#include<stdio.h> main() { int a,b,l; clrscr(); printf("/nEnter nos:"); scanf("%d%d",&a,&b); l=gcd(a,b); printf("GCD=%d",l); getch(); } gcd(int a,int b) { int c=0; while(1) { c=a%b; if(c==0) return b; a=b; b=c; } } o/p:
Enter nos:200 800 GCD=200
Source: CoolInterview.com
Posted by: AnuradhaSrikanth
Contact AnuradhaSrikanth
Source: CoolInterview.com
#include<stdio.h> int main(void) { int a,b,c,d,i,r1,r2,r3,r4,lst,gcd; printf("
Enter The Numbers"); scanf("%d %d %d %d", &a,&b,&c,&d); lst=a; if(b<lst) lst=b; if(c<lst) lst=c; if(c<lst) lst=d; for(i=2;i<=lst;i++) { r1=a%i; r2=b%i; r3=c%i; r4=d%i; if(r1==0 && r2==0 &&r3==0 && r4==0) gcd=i; else gcd=1; } printf("GCD=%d
", gcd); return 0; }
one back log of this program is that you cant use negetive numbers Source: CoolInterview.com
Posted by: debdeep
Contact debdeep
Source: CoolInterview.com
#include<stdio.h> #include<conio.h> struct gcd { int n; int b[100][10]; }k[4]; void main() { int a=0,i=0,m=0,z=0,v=1; int j[4],l[4],x,y; clrscr(); for(a=0;a<4;a++) { printf("Enter the value"); scanf("%d",&k[a].n); m=k[a].n; j[a]=0; l[a]=0; for(i=2;i<=m;i++) { while(m%i==0) { m=m/i; k[a].b[l[a]][j[a]]=i; j[a]=j[a]+1; } j[a]=0; l[a]=l[a]+1; } printf("
"); } for(x=0;x<10;x++) { for(y=0;y<10;y++) { if(k[0].b[x][y]&&k[1].b[x][y]&&k[2].b[x][y]&&k[3].b[x][y]) { printf("
common value are: %d",k[0].b[x][y]); v=v*k[0].b[x][y]; } } } printf("
gcd value is: %d",v); getch(); } Source: CoolInterview.com
Posted by: venkat
Contact venkat
Source: CoolInterview.com
what is this????????? Source: CoolInterview.com
Posted by: man
Contact man
Source: CoolInterview.com
1. First find out factors for the smallest number. 2. Which factors of smallest number gives reminder zero when divisible each factor with each number. 3. Take the common factors from four numbers and multiply them 4.Then you get Gcd.
ph no:+917842233607 Source: CoolInterview.com
Posted by: rajasekharreddy.bhumireddy
Contact rajasekharreddy.bhumireddy
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:
 There should not be any Spelling Mistakes.
 There should not be any Gramatical Errors.
 Answers must not contain any bad words.
 Answers should not be the repeat of same answer, already approved.
 Answer should be complete in itself.
