#navi(contents-page-name): No such page: 数値

絶対値を取得する・abs,labs,llabs

絶対値を取得するabs関数を使用したC言語サンプルコードを以下に記します。

c-top.html is not found or not readable.

関連記事

abs,labs,llabs関数書式など

abs,labs,llabs関数の3つの書式等は以下の通りです。

abs,labs,llabsを使用したC言語サンプルコード

&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;
}

abs,labs,llabsのC言語サンプルコードの実行結果

以下、コンパイルし実行した結果を記します。

$ 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.

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS