आपकी ऑफलाइन सहायता

BACK
49

सी प्रोग्रामिंग

149

पाइथन प्रोग्रामिंग

49

सी प्लस प्लस

99

जावा प्रोग्रामिंग

149

जावास्क्रिप्ट

49

एंगुलर जे.एस.

69

पी.एच.पी.
माय एस.क्यू.एल.

99

एस.क्यू.एल.

Free

एच.टी.एम.एल.

99

सी.एस.एस.

149

आर प्रोग्रामिंग

39

जे.एस.पी.





डाउनलोड पी.डी.एफ. ई-बुक्स
C - Find Lcm And Gcd Of Two Numbers

विवरण :

कोई विवरण नहीं है |


सोर्स कोड :

#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;
 }

आउटपुट :

Enter two numeric values : 55
5
LCM of 55 and 5 is 55
GCD of 55 and 5 is 5