img
Question:
Published on: 20 April, 2024

Write a C program to find the GCD of two numbers.

Answer:

 

#include<stdio.h>
#include<conio.h>
main()
{
	int a,b,r,t;
	printf("\n Enter two number");
	scanf("%d %d",&a,&b);
	if(a<b)
	{
		t=a;
		a=b;
		b=t;
	}
	do
	{
		r=a%b;
		a=b;
		b=r;
	}while(r!=0);
	printf("\n The GCD=%d",a);
	getch();
}


Output:

Random questions