Write a program to find HCF and LCM of two numbers
#include<stdio.h> void main() { int a,b,temp,temp1,temp2,rem; printf("Enter any two number:\n"); scanf("%d%d",&a,&b); if(a<b) { temp=a; a=b; b=temp; } temp1=a; temp2=b; while(b!=0) { rem=a/b; temp=b; b=a-rem*b; a=temp; } printf("HCF of %d & %d is %d\n",temp1,temp2,a); printf("LCM of %d & %d is %d",temp1,temp2,(temp1*temp2)/a); }
Output
Enter any two number:
30
55
HCF of 55 & 30 is 5
LCM of 55 & 30 is 330