+ 1
How to use absolute function in c language
General
3 ответов
+ 3
#include <stdio.h>
#include <stdlib.h>
int main(){
int a=-7;
int b=abs(a);
printf("%d",b);
}
//Prints 7
0
Rishabh Giri
absolute value of a value means changing the -ve value to +ve value and +ve remains +ve .
and since it is related to maths. it is made available in math.h header file
the syntax of abs() be like this
int abs(int a)
that means it takes a value and returns a positive integer
b = abs(-6)