Write a program that reads two integer values x and y and displays the absolute value of (x-y).

Execution example:
Enter x: -5
Enter y: 4

The absolute value obtained = 9


Difficulty level
This exercise is mostly suitable for students
#include <stdio.h>
#include <math.h>
int main()
{
    int x, y;
    printf("Enter 2 integers: ");
    scanf("%d %d", &x, &y);
    printf("|%d-%d|=%d",x,y,abs(x-y));
    
    return 0;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Merge 2 sorted arrays using an iterative function