training

Code I wrote during training
git clone git://git.bitsmanent.org/training
Log | Files | Refs | README

smpmm.c (778B)


      1 /* Esercizio 2.19 (Cap. 2)
      2    Visualizza la somma, media, prodotto,
      3    minore e maggiore di 3 interi. */
      4 
      5 #include <stdio.h>
      6 
      7 int main()
      8 {
      9    int a, b, c;
     10    int largest, smallest;
     11 
     12    printf("Input three different integers: ");
     13    scanf("%d%d%d", &a, &b, &c);
     14 
     15    printf("Sum is %d\n", a + b + c);
     16    printf("Average is %d\n", (a + b + c) / 3);
     17    printf("Product is %d\n", a * b * c);
     18  
     19    /* Trovo il > e il < di tre numeri (a, b, c) */
     20 
     21    if (a > b)
     22       largest = a;
     23  
     24    if (a < b)
     25       largest = b;
     26  
     27    if (c > largest)
     28       largest = c;
     29 
     30    if (a < b)
     31       smallest = a;
     32 
     33    if (a > b)
     34       smallest = b;
     35 
     36    if (c < smallest)
     37       smallest = c;
     38 
     39    printf("Smallest: %d\n", smallest);
     40    printf("Largest: %d\n", largest);
     41 
     42    return 0; 
     43      
     44 } /* E0F main */
     45