Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Dasprog C - 2019
- William Handi Wijaya
- 0087
- Program untuk menghitung jumlah dan rata-rata dari dua bilangan.
- */
- #include <stdio.h>
- double get_Double(void);
- int main(void)
- {
- printf("* * Compute the sum and average of two numbers. * *\n\n\n");
- double one, two, /* input - numbers to process */
- sum, /* output - sum of one and two */
- average; /* output - average of one and two */
- /* Get two numbers. */
- //Insert the first number;
- printf("Please insert the first number => ");
- one = get_Double();
- //insert the second number
- printf("Please insert the second number => ");
- two = get_Double();
- /* Compute sum of numbers. */
- //Sum the number that been set to variabel 'one' and 'two'
- sum = one + two;
- /* Compute average of numbers. */
- //Divide by two the sum of the two numbers that already been calculates before
- average = sum / 2;
- /* Display sum and average. */
- printf("Sum = %0.3f \nAverage = %0.3f\n\n", sum, average );
- return (0);
- }
- double get_Double(void)
- {
- double a;
- scanf("%lf", a);
- return a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement