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
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fit" instead of the number and for the multiples of five print "Bit". For numbers which are multiples of both three and five print "FitBit".
what are the 3 forms of a prolog term
What is the merger sort principle and its time complexity.
Q1.Write a C program which asks the user for a number between 1 to 9 and shows the number. If the user inputs a number out of the specified range, the program should show an error and prompt the user for a valid input.
what is apt_dump_score in datastage where it is useful
in cobol,wat is the difference in using 'set index in occurs clause' ....and 'occurs depending-on clause'
Can anyone send me NIC question papers alongwith answers on nidhi1485@yahoo.co.in? Urgently needed.. Thanks in advance
How to set on/off a group of indicators in a single statement?
differences between qtp10.0 and 11.0 ?
Write a program to find duplicate number from array in minimum time complexity.
Always use scope terminator like End-If with IF, End- Evaluate with Evaluate statement.Can somebody explain me the detail logical explanation?
Hi can you please help for the following. I have a ASP.Net web page I want to print the whole page how is it possible? I want It in ASP also.Please send me the solutions dipankar.hazari@gmail.com . Thanks in advance.
What is the difference between WebIntelligence and Designer in creating universes?
Suppose server object is not loaded into the memory, and the client request for it , what will happen?
what is the difference between an OS(operating system) and Framework?