Find Lcm And Gcd Of Two Numbers

in Hindi - Find Lcm And Gcd Of Two Numbers



not yet

Source Code :

RUN#include <stdio.h>
 
 int main()
 {
 int num1,num2,temp1,temp2,gcd,lcm;
 
 printf("Enter two numeric values : ");
 scanf("%d%d",&num1,&num2);
 
 temp1=num1;
 temp2=num2;
 
 if(temp1 == 0)
 {
 gcd=temp2;
 }
 else if(temp2 == 0)
 {
 gcd=temp1;
 }
 else
 {
 while(temp2 != 0)
 {
 if(temp1 > temp2)
 {
 temp1=temp1-temp2;
 }
 else
 {
 temp2=temp2-temp1;
 }
 gcd=temp1;
 }
 }
 lcm=(num1*num2) / gcd;
 printf("LCM of %d and %d is %ld\n",num1,num2,lcm);
 printf("GCD of %d and %d is %d\n",num1,num2,gcd);

 return 0;
 }