Menu
Coddy logo textTech

Average Value

Lesson 4 of 25 in Coddy's Coding Problems: Volume 2 course.

Create a program that reads 2 natural numbers from standard input. Find the average between the two (float), increase the first by that value, and decrease the second by that value. Finally, output the difference between the 2 new numbers

challenge icon

Challenge

Easy

The two natural numbers are given on standard input, write the program to find their average and do the calculation

Input
11 9

Output
Difference is: 22

Explanation
The average between 11 and 9 is 10, we increase 11 by 10, and we decrease 9 by then, we get 21 and -1, the difference between the two new numbers is 22

Try it yourself

#include <stdio.h>

int main() {
    // Write code here
    return 0;
}

All lessons in Coding Problems: Volume 2