Posts

Showing posts with the label new to programming

Find gcd, lcm of given two numbers.

Image
 Hello, budding developers. As the title says it all. We will write a program to find the gcd and lcm of two given numbers. Editor used: CodeBlocks Language used: C++ Program: #include <iostream> using namespace std; int main() {     int n1,n2,gcd=0,lcm=0;    cout<<"Enter number 1:";    cin>>n1;    cout<<"\nEnter number 2:";    cin>>n2;      int mult=n1*n2;    while(n1!=n2)    {        if(n1>n2)        {            n1=n1-n2;            gcd=n1;        }        else        {            n2=n2-n1;      ...