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 is a macro?

1064


What is a function simple definition?

1052


Why enum is used in c?

920


What is floating point constants?

1096


What are the different types of control structures?

1001


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

2488


Write a Program to find whether the given number or string is palindrome.

1248


What the different types of arrays in c?

1033


Is the exit() function same as the return statement? Explain.

1050


Is fortran still used today?

1061


What are Macros? What are its advantages and disadvantages?

1109


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

2055


List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.

2710


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

2392


What is use of integral promotions in c?

1096