About Lesson
Write a program that takes a number as input and outputs its absolute value.
#include <stdio.h>
int main() {
// Declare variables
float number;// Input: Get a number from the user
printf(“Enter a number: “);
scanf(“%f”, &number);// Process: Calculate and output the absolute value
if (number < 0) {
printf(“The absolute value of %.2f is %.2fn”, number, -number);
} else {
printf(“The absolute value of %.2f is %.2fn”, number, number);
}return 0; // Exit the program successfully
}