C 库函数 - labs()

C 语言教程 · 2019-02-24 10:26:56

描述

C 库函数 long int labs(long int x) 返回 x 的绝对值。

声明

下面是 labs() 函数的声明。

long int labs(long int x)

参数

  • x -- 完整的值。

返回值

该函数返回 x 的绝对值。

实例

下面的实例演示了 labs() 函数的用法。

#include <stdio.h>
#include <stdlib.h>

int main ()
{
   long int a,b;

   a = labs(65987L);
   printf("a 的值 = %ld\n", a);

   b = labs(-1005090L);
   printf("b 的值 = %ld\n", b);
   
   return(0);
}

让我们编译并运行上面的程序,这将产生以下结果:

a 的值 = 65987
b 的值 = 1005090

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

Single Page Web Applications

Single Page Web Applications

Michael Mikowski、Josh Powell / Manning Publications / 2013-9-30 / USD 44.99

Code for most web sites mostly runs on the server. When a user clicks on a link, the site reacts slowly because the browser sends information to the server and the server sends it back again before di......一起来看看 《Single Page Web Applications》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换