絶対値を取得するabs関数を使用したC言語サンプルコードを以下に記します。
c-top.html is not found or not readable.abs,labs,llabs関数の3つの書式等は以下の通りです。
#include <stdlib.h>
int abs(int j);
long int labs(long int j);
long long int llabs(long long int j);
&ref(): File not found: "abs.c" at page "数値/絶対値を取得する・abs,labs,llabs"; (改行コードLF)
#include <stdio.h> #include <stdlib.h> int main(void) { int i; long l; long long ll; i = -100; l = -200000; ll = -30000000; printf("abs(i) : %d\n", abs(i)); printf("labs(l) : %ld\n", labs(l)); printf("llabs(ll) : %lld\n", llabs(ll)); return 0; }
以下、コンパイルし実行した結果を記します。
$ gcc abs.c -o abs $ ./abs abs(i) : 100 labs(l) : 200000 llabs(ll) : 30000000
以上、abs, labs, llabs関数のC言語サンプルコードでした。
c-btm.html is not found or not readable.