C Program to Find Average of Two Numbers

Write C Program to Find Average of Two Integer Numbers

#include<stdio.h>

int main()
{
	int n1 , n2;

	printf("Enter the Number 1 :--> ");
	scanf("%d", &n1);

	printf("Enter the Number 2 :--> ");
	scanf("%d", &n2);

	float avg = (n1 + n2) / (2.0);

	printf("Average: (%d + %d)/2 = %f", n1, n2, avg);

	return 0;
}

Output:

Enter the Number 1 :–> 2
Enter the Number 2 :–> 3

Average: (30 + 40) = 35.000000


<< Previous | Next >>