3

C Program to Find Absolute Value of a Given Number

 2 years ago
source link: https://www.geeksforgeeks.org/videos/c-program-to-find-absolute-value-of-a-given-number/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

C Program to Find Absolute Value of a Given Number

C Program to Find Absolute Value of a Given Number
Hello, friends. Welcome back to the instructions. So,
  • 10 Views
  • 04/08/2022

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/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK