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

Explain the difference between an expert and a novice user. How would your strategy for designing user interfaces for an expert user differ from that for designing user interfaces for a novice user.

2614


how do you generate source code for the automatic generation for receipt number

3828


What is the use of Differ interface check box in Ship confirm?

1848


What is the difference beween joblib and steplib statements

1784


What is BASIS

1666






Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming

11129


what are the 3 forms of a prolog term

2753


what is delimiter in sas ?

1545


what is the last ant version you worked?how to get it

1462


how we can know the funcions available in a class recording java?

1752


Hey this is venkatesh.Please can any body tell me what is SFLNXTCHG?where we use this keyword?what perpuse we use this?Can you tell me in real time senario with example? And in 7 specification(RPG/400)what is the mandatory specification using programs?

1527


What is the difference between COM and CORBA?

730


Difference of Console, web & windows applications?

1590


what will we require to build project with the help of oracle

1388


how to display xisheet in list box in c# .net

1627