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

what are the advantages of sap on other software ?

1727


hi..this is kartheek..complted mca in 2009..but i dont have knowledge in programing..but to learn new language.. which one is suitable for me?is SAP or IBM mainframes is suitable for me..?if it suits how much will it costs..?pls answer...

1544


hai i am prasanna.I am MCA 2009 fresher.tell me about certifications.which certification helps me to improve my carrier and to get a technically oriented job ,which certification helps to get job faster.

2014


Hi..Am done with my Masters recently..Am planning to learn TIBCO.. could anyone suggest me about how the job market will be and Is there any course necessary to learn prior to Tibco..i mean any prerequisite. I dnt have any knowledge on PL/SQL thats it... Plz suggest me in a best way...

1781


Given a Binary Search Tree, write a program to print the kth smallest element without using any static/global variable. You can?t pass the value k to any function also.

552






Hi All, Can any one please send me the difference between informatica 7i and 8i versions, Thanks in advance. vinod

1530


Difference between debugging, running, executing of an application

3482


write a sql qwery which include joining of two tables 4 marks mainframe

1486


You are given some denominations of coins in an array (int denom[])and infinite supply of all of them. Given an amount (int amount), find the minimum number of coins required to get the exact amount. What is the method called?

601


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

1382


what is log files in qtp what is use

1585


design a counter with the following repeated binary sequence: 0, 1, 2, 3, 4, 5, 6, 7, 8 using JK Flip Flop.

16216


can any one suggestion me present which course(except java,.net) has huge demand in the market?

1613


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

1459


Code for display the images from drive using vb 6.0?

4279