Computer Science, asked by manojshaw1002, 4 months ago

c++ programme for finding the hcf of 2 inputted numbers​

Answers

Answered by himanshu2006vps
0

Answer:

#include <iostream>

using namespace std;

int main() {

int i, num1, num2, min, hcf=1;

// Take two numbers from user

cout << "Enter two numbers : ";

cin >> num1 >> num2;

// Find minimum between two numbers

min = num1;

if(num2 < num1) {

min = num2;

}

for(i = 1; i <= min; i++) {

if((num1 % i) == 0 && (num2 % i) == 0) {

hcf = i;

}

}

cout << endl << "HCF of " << num1 << " and " << num2 << " : " << hcf;

return 0;

}

Similar questions