2
Answers

Conversion from C++ to C#

Rushal Arora

Rushal Arora

10y
31.3k
1

#include "iostream"

using namespace std;

int main()
{
    int num1,num2,hcf=0,cont=0,lcm;

    do{
    cout<<"Enter 2 number to find H.C.F OR G.C.D"<<endl;
    cin>>num1>>num2;
    for(int i=1;i<=num1 && i<=num2;i++)
    {
        if((num1%i == 0)&&(num2%i==0))
        {
            hcf=i;
        }
    }
    cout<<"HCF ="<<hcf<<endl;
   
    lcm=(num1*num2)/hcf;

    cout<<"L.C.M = "<<lcm<<endl;

    cout<<"want to continue"<<endl;
    cin>>cont;
    }while(cont>0);

    return 0;
}


Answers (2)