how we do lcm of two no using c simple if while or for
statement
Answer Posted / aditya goel
#include<stdio.h>
#include<conio.h>
main()
{
int lcm=1,a,b,c,d,x;
clrscr():
printf("Enter any two numbers:\n");
scanf("%d %d",&a,&b);
c=a;d=b;
x=(a<b)?a:b;
for(i=2;i<=x;i++)
{
if ((a%i==0) && (b%i==0))
{
lcm=lcm*i;c=c/i;d=d/i;
}
else if (a%i==0)
{
lcm=lcm*i;c=c/i
}
else if (b%i==0)
{
lcm=lcm*i;d=d/i;
}
}
lcm=lcm*c*d;
printf("lcm is %d",lcm);
getch();
}
| Is This Answer Correct ? | 3 Yes | 13 No |
Post New Answer View All Answers
Why do we use main function?
hi folks i m approching for h1 b interview on monday 8th of august at montreal and i m having little problem in my approval notice abt my bithdate my employer has made a mistake while applying it is 12th january and istead of that he had done 18 the of january do any body have any solution for that if yes how can i prove my visa officer abt my real birthdate it urgent please let me know guys thaks dipesh patel
Write a program of prime number using recursion.
If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402
What is far pointer in c?
Are the variables argc and argv are local to main?
write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.
What is the acronym for ansi?
Why C language is a procedural language?
write an algorithm to display a square matrix.
Subtract Two Number Without Using Subtraction Operator
hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..
Explain what math functions are available for integers? For floating point?
which is conditional construct a) if statement b) switch statement c) while/for d) goto
Which of these functions is safer to use : fgets(), gets()? Why?