how we do lcm of two no using c simple if while or for
statement
Answer / 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 |
hi any body pls give me company name interview conduct "c" language only
Can we assign integer value to char in c?
What is the difference between void main() and void main (void) give example programme?
application attempts to perform an operation?
write a fuction for accepting and replacing lowercase letter to'Z' with out using inline function.
Design a program using an array that lists even numbers and odd numbers separately from the 12 numbers supplied by a user.
what is the difference between malloc() and calloc() function?
Are the variables argc and argv are local to main?
Once I have used freopen, how can I get the original stdout (or stdin) back?
Is sizeof a keyword in c?
write a program of bubble sort using pointer?
What is && in c programming?