Find GCD or HCF of Two Numbers
In this program we learn how to calculate GCD or HCF of two numbers by provided user using C.C program to calculate GCD or HCF of two numbers
// FIND GCD OR HCF OF TWO NUMBERS
#include<stdio.h>
#include<conio.h>
void main()
{
int g, a, b, r;
clrscr();
printf("\n Enter two number : ");
scanf("%d%d",&a,&b);
do
{
r = a % b;
a = b;
b = r;
}while(r != 0);
printf("\n The G.C.D = %d",a);
getch();
}
OUTPUT:
Enter two numbers : 27 9
The G.C.D = 9
The G.C.D = 9
No comments:
Post a Comment