C Program to find GCD and LCM of a given two number

Program

#include<stdio.h>
void main()
{
	int a, b, gcd = 0, lcm = 0;
	int temp_a, temp_b;
	printf("Enter two numbers\n");
	scanf("%d %d", &a, &b);
	temp_a = a;
	temp_b = b;
	do
	{
		gcd = a % b;
		a = b;
		b = gcd;
	}while(gcd);
	printf("GCD of %d and %d is %d\n", temp_a, temp_b, a);
	lcm = (temp_a * temp_b) / 2;
	printf("LCM of %d and %d is %d\n", temp_a, temp_b, lcm);
}

Output

Enter two numbers
30
12
GCD of 30 and 12 is 6
LCM of 30 and 12 is 180