Write a program using a float type AVERAGE function to display the arithmetic mean of two real numbers entered on the keyboard.


Difficulty level
Video recording
This exercise is mostly suitable for students
#include <stdio.h>
#include <conio.h>

float average(float X, float Y)
{
 	return (X+Y)/2;
}

void main()
{
	float a, b;

	printf("Enter 2 integers: ");
	scanf("%f %f", &a, &b);

	printf("The average of %f and %f is equal to %f.", a, b, average(a, b));

	getch();
}

 

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Program output 9