SAADQUAMER

GCD and LCM of two Numbers

Jun 21st, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. //C Program to Find GCD and LCM of two Numbers.
  2. #include<stdio.h>
  3. int main(){
  4.  
  5. int x1,x2,mod,num1,num2,gcd;
  6. printf("Enter Two Number :");
  7. scanf("%d%d",&x1,&x2);
  8. num1=x1;
  9. num2=x2;
  10. while(num2!=0){
  11.     mod = num1%num2;
  12.     num1 = num2;
  13.     num2 = mod;
  14. }
  15.  
  16. printf("GCD of two number is :%d\n",num1);
  17. printf("LCM of two number is :%d\n",((x1*x2)/num1));
  18.  
  19.  
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment