• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
August 04, 2022 |5.7K Views
C Program to Find Absolute Value of a Given Number
  Share   Like
Description
Discussion

In this video, we will write a C Program to Find Absolute Value of a Given Number

What is absolute value?
The absolute value of any number is always positive. For any positive number, the absolute value is the number itself and for any negative number, the absolute value is (-1) multiplied by the negative number. 

Examples: 
Input: N = -23 
Output: 23 
Input: N = 45 
Output: 45 

There are two different approaches to find absolute value of a given numbers: 

1. Using if-else condition: In this method, simply if-else conditions are used. 
Here the Time Complexity is O(1) and Auxiliary Space is O(1). 

2. Using ABS_Value: The inbuilt function ABS_Value() in stdlib.h library finds the absolute value of any number. 
Here the Time Complexity is O(1) and Auxiliary Space is O(1). 

Program to find absolute value of a given number:
https://www.geeksforgeeks.org/program-to-find-absolute-value-of-a-given-number/

Read More