Advertisement
frain8

Untitled

Nov 21st, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.15 KB | None | 0 0
  1. /* Dasprog C - 2019
  2. William Handi Wijaya
  3. 0087
  4.  
  5. Program untuk menghitung jumlah dan rata-rata dari dua bilangan.
  6. */
  7.  
  8.  
  9. #include <stdio.h>
  10.  
  11. double get_Double(void);
  12.  
  13. int main(void)
  14. {      
  15.     printf("* * Compute the sum and average of two numbers. * *\n\n\n");
  16.     double  one, two, /* input - numbers to process       */            
  17.             sum,      /* output - sum of one and two      */            
  18.             average;  /* output - average of one and two  */    
  19.        
  20.     /* Get two numbers. */  
  21.         //Insert the first number;
  22.         printf("Please insert the first number => ");
  23.         one = get_Double();
  24.    
  25.     //insert the second number
  26.         printf("Please insert the second number => ");
  27.         two = get_Double();
  28.        
  29.     /* Compute sum of numbers. */
  30.         //Sum the number that been set to variabel 'one' and 'two'
  31.         sum = one + two;
  32.          
  33.     /* Compute average of numbers. */
  34.         //Divide by two the sum of the two numbers that already been calculates before
  35.         average = sum / 2;
  36.              
  37.     /* Display sum and average. */
  38.     printf("Sum = %0.3f \nAverage = %0.3f\n\n", sum, average );
  39.     return (0);
  40. }
  41.  
  42. double get_Double(void)
  43. {
  44.     double a;
  45.     scanf("%lf", a);
  46.     return a;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement