Write a program that reads an integer from the keyboard and displays its absolute value.
Difficulty level

This exercise is mostly suitable for students
#include <stdio.h>
#include<conio.h>
void main()
{
int n;
/* Read */
printf("Enter an integer : ");
scanf("%d", &n);
/* Calculation and dislay */
if (n < 0)
n = -n;
printf("Abs = %d\n", n);
getch();
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
