Computer C++ program to find the LCM and GCD of two numbers

Computer C++ program to find the LCM and GCD of two numbers

#include
#include

void main()
{
clrscr();

int x,y,gcd=1;

cout<< "ENTER 1st NO : "; cin>>x;

cout<<"\n\nEnter 2nd NO. :"; cin>>y;

for(int i=1;i<1000;++i)
{
if((x%i==0)&&(y%i==0))
gcd=i;
}

cout<<"\n\n\nGCD :"<
cout<<"\n\n\nLCM :"<<(x*y)/gcd;

getch();
}


OUTPUT:

ENTER 1st NO : 12

ENTER 2nd NO. :13

GCD :1

LCM :156

0 comments

Search

Loading...

Archive

CBSE 2010

CBSE 2011

CBSE 2012

CBSE 2013

CBSE 2014

CBSE 2015

CBSE 2016

CBSE 2017