Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how we do lcm of two no using c simple if while or for
statement



how we do lcm of two no using c simple if while or for statement..

Answer / aditya goel

#include<stdio.h>
#include<conio.h>
main()
{
int lcm=1,a,b,c,d,x;
clrscr():
printf("Enter any two numbers:\n");
scanf("%d %d",&a,&b);
c=a;d=b;
x=(a<b)?a:b;
for(i=2;i<=x;i++)
{
if ((a%i==0) && (b%i==0))
{
lcm=lcm*i;c=c/i;d=d/i;
}
else if (a%i==0)
{
lcm=lcm*i;c=c/i
}
else if (b%i==0)
{
lcm=lcm*i;d=d/i;
}
}
lcm=lcm*c*d;
printf("lcm is %d",lcm);
getch();
}

Is This Answer Correct ?    3 Yes 13 No

Post New Answer

More C Interview Questions

hi any body pls give me company name interview conduct "c" language only

0 Answers  


Can we assign integer value to char in c?

0 Answers  


What is the difference between void main() and void main (void) give example programme?

0 Answers  


application attempts to perform an operation?

0 Answers  


write a fuction for accepting and replacing lowercase letter to'Z' with out using inline function.

5 Answers   Temenos,


Design a program using an array that lists even numbers and odd numbers separately from the 12 numbers supplied by a user.

8 Answers  


what is the difference between malloc() and calloc() function?

1 Answers  


Are the variables argc and argv are local to main?

0 Answers   TISL,


Once I have used freopen, how can I get the original stdout (or stdin) back?

0 Answers  


Is sizeof a keyword in c?

0 Answers  


write a program of bubble sort using pointer?

3 Answers   TCS,


What is && in c programming?

0 Answers  


Categories