SHARE
TWEET

Esercizio 6 (Tutoraggio CE)

MartaFraioli Oct 20th, 2019 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main(void){
  4.     int a, b, r;
  5.     printf("Inserisci due numeri di cui vuoi trovare MCD e mcm\n");
  6.     scanf("%d\n%d", &a, &b);
  7.     int num = a*b;
  8.     if(b>a){ int h = a;
  9.         a = b;
  10.         b = h;
  11.     }
  12.     while(b != 0){
  13.         r = a % b;
  14.         a = b;
  15.         b = r;
  16.  
  17.     }
  18.     printf("Il MCD tra i due numeri e': %d\n", a);
  19.     int mcm = num / a;
  20.     printf("Il mcm tra i due numeri e': %d", mcm);
  21.     return 0;
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top