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...

Write a Pseudo Code to fins the LCM of two given numbers

Answer Posted / mohit

#include <stdio.h>


main()
{
int a,b,n=2,res=1;
printf("Enter two integers : ");
scanf("%d %d",&a,&b);
while((a!=1)||(b!=1))
{
if((a%n==0)&&(b%n==0))
{
a/=n;
b/=n;
res*=n;
}

else if((a%n==0)&&(b%n!=0))
{
a/=n;
res*=n;

}

else if((a%n!=0)&&(b%n==0))
{
b/=n;
res*=n;

}

else if((a%n!=0)&&(b%n!=0))
{
n++;
}

}
printf("\n LCM of a and b is %d",res);

}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

in teradata level primary in table level allows duplicates why?

2149


1.what is the vesition managment.

2238


Write a shell program. Enter number of days from keyboard. Find out the number of years, month and days it contains

2136


what is log files in qtp what is use

2097


What binary value will be internally stored for NULL for the type S9(1) COMP 3 in mainframe

2023


please any one pass file aid,xpeditor and endeavor tools

2391


hi, all this is shoba m.c.a . i have learned abap but no oppurtunities right now as fresher , right now i want to learn any course on demand any one pls suggest me good course and institute in hyderabad

1854


what are other resources are needed for this mantis?

2010


what is the similarity between networking devices?

2273


how can we maintain the previous version scripts to new version.

2000


Write a program to find whether a given number is prime or not.

1089


Suppose server object is not loaded into the memory, and the client request for it , what will happen?

2725


Why did you ever become involved in QA/testing?

2126


What is the merger sort principle and its time complexity.

1233


i want to insert textbox value to sql db. i have only one text box but store four values. ple give any one give sample code in asp.net c#..

3715