Computer Science, asked by roshnipandit0015, 7 months ago

Srite a program to evaluate the Hcf of two positive integers​

Answers

Answered by Anonymous
2

\huge\underline\bold \blue {♡AnswEr♡}</p><p>

Input two numbers from user. Store them in some variable say num1 and num2 . Declare and initialize a variable to hold hcf i.e. hcf = 1 . ... Inside the loop check if i is a factor of two numbers i.e. if i exactly divides the given two numbers num1 and num2 then set i as HCF i.e. hcf = i .

Answered by simran5972
2

Answer:

Input two numbers from user. Store them in some variable say num1 and num2.

Declare and initialize a variable to hold hcf i.e. hcf = 1.

Find minimum between the given two numbers. Store the result in some variable say min = (num1<num2) ? num1 : num2;.

Run a loop from 1 to min, increment loop by 1 in each iteration. The loop structure should look like for(i=1; i<=min; i++).

Inside the loop check if i is a factor of two numbers i.e. if i exactly divides the given two numbers num1 and num2 then set i as HCF i.e. hcf = i.

please mark me as brainlst

Similar questions