Fabs (jazyk C): Rozdiel medzi revíziami
Skočit na navigaci
Skočit na vyhledávání
d (→Funkcia abs) |
d (→Príklad) |
||
Riadok 35: | Riadok 35: | ||
} | } | ||
</source> | </source> | ||
− | + | ''Výstup:'' | |
Absolutna hodnota cisla 3.1416 je 3.141600 | Absolutna hodnota cisla 3.1416 je 3.141600 | ||
Absolutna hodnota cisla -10.6 je 10.600000 | Absolutna hodnota cisla -10.6 je 10.600000 |
Aktuálna revízia z 23:23, 19. máj 2020
<ctype.h> | <limits.h> | <stdio.h> | <stdlib.h> | <math.h> | <string.h> | <time.h> |
---|---|---|---|---|---|---|
isalnum |
printf |
system |
Funkcia fabs
knižnica | math.h |
popis | Vypočíta absolútnu hodnotu reálneho čísla |
Úplný funkčný prototyp:
double fabs ( double x );
float fabs ( float x );
long double fabs ( long double x );
Podrobný popis funkcie
Vypočíta absolútnu hodnotu parametra x.
Parametre
- x
- číslo s reálnou hodnotou
Návratová hodnota
Absolútna hodnota vstupného parametra x.
Príklad
1 #include <stdio.h>
2 #include <math.h>
3
4 int main ()
5 {
6 printf ("Absolutna hodnota cisla 3.1416 je %lf\n", fabs (3.1416) );
7 printf ("Absolutna hodnota cisla -10.6 je %lf\n", fabs (-10.6) );
8 return 0;
9 }
Výstup:
Absolutna hodnota cisla 3.1416 je 3.141600 Absolutna hodnota cisla -10.6 je 10.600000