Skip to main content

Average of two numbers

#include <stdio.h>
int main()
{
  int a, b;
  float avg;
  printf("Enter two numbers\t:\t");
  scanf("%d%d", &a , &b );
  avg = (float) (a + b) / 2;
  printf("The average of %d and %d is %f", a, b, avg);

  return 0;
}

Enter two numbers :  5 6
The average of 5 and 6 is 5.500000 


Comments