Labs (jazyk C)
Skočit na navigaci
Skočit na vyhledávání
<ctype.h> | <limits.h> | <stdio.h> | <stdlib.h> | <math.h> | <string.h> | <time.h> |
---|---|---|---|---|---|---|
isalnum |
printf |
system |
Funkcia labs
knižnica | stdlib.h |
popis | Vráti absolútnu hodnotu čísla. |
Úplný funkčný prototyp:
long int labs(long int x)
Podrobný popis funkcie
Funkcia vráti absolútnu hodnotu čísla x.
Parametre
- x
- Číslo, ktorého absolútna hodnota bude vrátená.
Návratová hodnota
Funkcia vráti vráti absolútnu hodnotu čísla x.
Príklad
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 int main() {
5 long int a, b;
6
7 a = labs(65987L);
8 printf("Hodnota cisla a = %ld\n", a);
9
10 b = labs(-1005090L);
11 printf("Hodnota cisla b = %ld\n", b);
12
13 return 0;
14 }
Výstup:
Hodnota cisla a = 65987 Hodnota cisla b = 1005090