Sponsored Links

Interview Questions



INTERVIEW QUESTIONS PROGRAMMING LANGUAGES C DETAILS

Question: How to find GCD of four numbers?

Answer: 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)

Category C Interview Questions & Answers - Exam Mode / Learning Mode
Rating (0.2) By 9311 users
Added on 3/29/2014
Views 71204
Rate it!

Question: How to find GCD of four numbers?

Answer:

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

Answered by: prasenjit | Date: 4/14/2009 | Contact prasenjit Contact prasenjit

Global coding data Source: CoolInterview.com

Answered by: saumya | Date: 4/17/2009 | Contact saumya Contact saumya

#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

Answered by: Aj | Date: 10/6/2009 | Contact Aj Contact Aj

#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

Answered by: AnuradhaSrikanth | Date: 1/26/2010 | Contact AnuradhaSrikanth Contact AnuradhaSrikanth

#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

Answered by: debdeep | Date: 3/21/2010 | Contact debdeep Contact debdeep

#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

Answered by: venkat | Date: 7/12/2010 | Contact venkat Contact venkat

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

Answered by: man | Date: 8/18/2010 | Contact man Contact man

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

Answered by: rajasekharreddy.bhumireddy | Date: 9/4/2010 | 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 - Exam Mode / Learning Mode



User Options
India News Network

Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal



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-2024 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions