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

Write a program to show polymorphism.

842


Please describe an example where you used object orientation in one of your programs.

1668


I am looking for selenium RC online Training in chennai. can any one tell me the best institute

1708


1) How can u create the table?

1584


how can i split string in a textbox in windows appication using C#.net

2415






what is the software to run the GSM gate opener program

1913


19. Given a system that is described with the following equation, X=A+(B.(A̅+C)+C)+A.B.(D̅+E̅) a) Simplify the equation using Boolean Algebra. b) Implement the original and then the simplified equation with a digital circuit. c) Implement the original and then the simplified equation in ladder logic.

1432


hi i am jyoti i have done sap training in sd and master degree in economics have 2 year exp as enduser in (gdms)and 1 year as sd consultant.as contract basis now what i can do for getting job in it industry

1869


hi this is uday i want prepare for nic exam if any one have previous question papers please send me or atlest guide me how to prepare my ID is udaykiran4u@in.com

1664


What is SOLID Principle in Programming Language?

869


sample and simple coding where we get?

1984


1.what is the vesition managment.

1892


why not instantiating servet using new operator?

1691


WHAT IS THE MEANING OF CONSTANT ...EXEEDS LENGTH LIMIT WHILE COPYING FROM PS FILE TO KSDS

1769


3 members in a pf.how we read 3 members without using ovrdbf.using rg pgms....

1874