Computer Science, asked by moonarmy4425, 1 year ago

Write a c++ program to find gcd of two number using while loop

Answers

Answered by shashanknenar
4

Answer:

#include <stdio.h>

int main()

{

int n1, n2;

printf("Enter two positive integers: ");

scanf("%d %d",&n1,&n2);

while(n1!=n2)

{

if(n1 > n2)

n1 -= n2;

else

n2 -= n1;

}

printf("GCD = %d",n1);

return 0;

}

Explanation:

its simple and understandable

Similar questions