CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Interview Success Kit - Get Success in Job Interviews Interview Success Kit - 30,000 Interview Que. & Ans.
Covers 30,000+ Interview Questions asked in actual MNC Interviews - all with model answers.

Sponsored Links

Interview Questions
Our Services

INTERVIEW QUESTIONS PROGRAMMING LANGUAGES C DETAILS
Question :
How to find GCD of four numbers?

Posted by: vinayak on 3/29/2014

Contact vinayak Contact vinayak
Category C Interview Questions
Rating (3.8) By 46 users
Added on 3/29/2014
Views 455
Rate it!


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
smallest-5
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 Contact prasenjit

Source: CoolInterview.com

Global coding data
Source: CoolInterview.com



Posted by: saumya

Contact 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 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 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 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 Contact venkat

Source: CoolInterview.com

what is this?????????
Source: CoolInterview.com



Posted by: man

Contact 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 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.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification Enter the above shown code: *
    Inform me about updated answers to this question

    Related Questions
    View Answer
    Write a program to accept any number up to six digit and print in words.
    for ex:1234=one two three four
    View Answer
    What is type integration? And what is integer type integration?
    View Answer
    What is :- Token , identifier , block , parameter , argument , scope of variable , Macro ?
    View Answer
    What is the code to find our age,for example if my date of birth is 4/12/1986 and today date is 16/11/2008
    answer should give our year,month,no of days
    View Answer
    What is the difference between unix and linux.
    View Answer
    How to convert decimal to octal and hexadecimal?
    View Answer
    If we want that any wildcard characters in the command line argument should be approxiemately expanded , are we required to make any special provision?if yes, which?
    View Answer
    How would you obtain the current time and difference between two times?
    View Answer
    What is a default TCP/IP socket assigned for SQL Server?
    View Answer
    #include <stdio.h>
    int main()
    {

    int a=3, b = 5;
    printf(&a["Ya!Hello! how is this? %s
    "], &b["junk/super"]);
    printf(&a["WHAT%c%c%c
    %c%c
    %c !
    "], 1["this"],
    2["beauty"],0["tool"],0["is"],3["sensitive"],4["CCCCCC"]);

    return 0;
    }
    View Answer
    How i can run *.bat or *.cmd file by using system function in c ?
    View Answer
    Why does a linker error occurs for the segment:
    main()
    {
    extern int i;
    i=20;
    printf("%d",sizeof(i));
    }
    View Answer
    Can there be a mouse click and drag function used together to rotate a circle in c?please give which are they?
    View Answer

    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL C Interview Questions & Answers

    User Options
    India News Network

    Latest 20 Questions
    What is Yield to Maturity in Futures and Options Trading Market?
    What is Yield Curve in Futures and Options Trading Market?
    Who is a Writer in Futures and Options Trading Market?
    What is Wire House in Futures and Options Trading Market?
    What is Warehouse Receipt in Futures and Options Trading Market?
    What is Vertical Spread in Futures and Options Trading Market?
    What is Variable Limit in Futures and Options Trading Market?
    What is Underlying Security in Futures and Options Trading Market?
    What is Underlying Futures Contract in Futures and Options Trading Market?
    What is Uncovered put writing in Futures and Options Trading Market?
    What is Uncovered call writing in Futures and Options Trading Market?
    What is U.S. Treasury Note in Futures and Options Trading Market?
    What is U.S. Treasury Bond in Futures and Options Trading Market?
    What is U.S. Treasury Bill in Futures and Options Trading Market?
    What is Type in Futures and Options Trading Market?
    What is Trade Balance in Futures and Options Trading Market?
    What is Time-Stamp in Futures and Options Trading Market?
    What is Time Value in Futures and Options Trading Market?
    What is Time Limit Order in Futures and Options Trading Market?
    What is Time and Sales Ticker in Futures and Options Trading Market?



    Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

    Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

    MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
    MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

    GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

    IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
    IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

    SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
    SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |




    Copyright ©2003-2016 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions



    Cache = 0.007812 Seconds