Skip to main content

Absolute difference between two numbers

#include <stdio.h>
#include<stdlib.h> // since we are using abs() function
int main()
{
  int a,b,c;
  printf("Enter two numbers\t:\t");
  scanf("%d%d", &a , &b );
  c= abs (a - b);
  printf("The absolute difference between %d and %d is %d", a, b, c);

  return 0;
}

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

Comments