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
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.
how do you generate source code for the automatic generation for receipt number
What is the use of Differ interface check box in Ship confirm?
What is the difference beween joblib and steplib statements
What is BASIS
Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming
what are the 3 forms of a prolog term
what is delimiter in sas ?
what is the last ant version you worked?how to get it
how we can know the funcions available in a class recording java?
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?
What is the difference between COM and CORBA?
Difference of Console, web & windows applications?
what will we require to build project with the help of oracle
how to display xisheet in list box in c# .net