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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the __date__ and __time__ preprocessor commands?

1092


What is double pointer?

988


Explain built-in function?

1123


write a program to find out prime number using sieve case?

2079


what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above

1109


How can I remove the trailing spaces from a string?

1064


What are the uses of a pointer?

1144


Is swift based on c?

1090


What are the advantages of external class?

1050


Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent

2114


Explain what header files do I need in order to define the standard library functions I use?

1159


what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555

3055


Why array is used in c?

1005


Which is best linux os?

1017


what is the structure pointer?

2110