/* Program to find LCM/HCF of 15 Nos in C++/ C (replace cin with scanf & cout with printf for c) */
/* Developed by - Kishore Kr. Banerjee - papillon_kish@Yahoo.com */
#include <iostream.h>
#include <conio.h>
main()
{
int num[3],i,j,p,q,tmp,n1,n2,LCM,rem,flag;
clrscr();
for(i=0;i<3;i=i+1)
{
cout<<"Enter No - "<<i+1<<"=";
cin>>num[i];
}
clrscr();
n1=num[0];
p=n1;
for(i=1;i<3;i=i+1)
{
n2=num[i];
/* Finding HCF */
q=n2;
if(p<q)
{
tmp=q;
q=p;
p=tmp;
}
while(p%q!=0)
{
rem=p%q;
q=p;
p=rem;
if(p<q)
{
tmp=q;
q=p;
p=tmp;
}
}
/*finding LCM */
LCM=1;
for(j=1;n1%j==0n2%j==0;j=j+1)
{
if(n1%j==0)
{
n1=n1/j;
flag=1;
}
if(n2%j==0)
{
n2=n2/j;
flag=1;
}
if(flag==1)
{
LCM=LCM*j;
}
}
LCM=LCM*n1*n2;
n1=LCM;
}
cout<<"the LCM ="<<LCM;
cout<<"the hcf ="<<q;
getch();
}
-----
int gcd (int a, int b)
{
. int tmp;
. if (a<0) a= -a;
. if (b<0) b= -b;
. if (a<b) tmp= a, a= b, b= tmp;
. while (b) {
. . tmp= a%b;
. . a= b;
. . b= tmp;
. }
. return a;
}
int gcd_n (int n, const int *vect)
{
. int i, gcdtmp;
. for (i=0, gcdtmp=0; i<n && gcdtmp!=1; ++i)
. . gcdtmp= gcd (gcdtmp, vect[i]);
. return gcdtmp;
}
int LCM (int a, int b)
{
. int d= gcd (a, b);
. if (d==0) return d;
. else return a/d*b;
}
int lcm_n (int n, const int *vect)
{
. int i, lcmtmp;
. for (i=0, lcmtmp=1; i<n; ++i)
. . lcmtmp= LCM (lcmtmp, vect[i]);
. return lcmtmp;
}
fdsgfhgdfhgdf
program to find maximum of two numbers using pointers
VBnet program to find the prime numbers between 100 to 200?
By learning how to program on C+.
Rewrite the above program so that the program accepts any value for the radius then recalculate the area of the circle.
question clarity
write a lex program to delete space from the program
write an assembly language program to find sum of N numbers
hey i m going to give a program that accepts edges a input and then it draws the graph using a computer graphics display...
Write 2 ways in which whole numbers and decimal numbers are different
write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? check bellow link http://bashscript.blogspot.com/2009/08/gcd-of-more-than-two-numbers.html
fdsgfhgdfhgdf
How to write a program for mouse in microprocessor?
1. Accept the 2 numbers 2. Add the 2 numbers3. Compare answer with 54. If answer is greater than 5 subtract with 5 else give a error message.
program to find maximum of two numbers using pointers
write it in 8085
To write a C++ program to display the student details using class and array of object.