C 语言实例 - 判断正数/负数

C 语言教程 · 2019-02-20 17:43:27

用户输入一个数字,判断该数字是正数还是负数或是零。

实例

#include <stdio.h> int main() { double number; printf("输入一个数字: "); scanf("%lf", &number); if (number <= 0.0) { if (number == 0.0) printf("你输入的是 0。"); else printf("你输入的是负数。"); } else printf("你输入的是正数。"); return 0; }

运行结果:

输入一个数字: 9
你输入的是正数。

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

查看所有标签

Learning PHP, MySQL, JavaScript, and CSS

Learning PHP, MySQL, JavaScript, and CSS

Robin Nixon / O'Reilly Media / 2012-9-3 / USD 39.99

If you're familiar with HTML, you can quickly learn how to build interactive, data-driven websites with the powerful combination of PHP, MySQL, and JavaScript - the top technologies for creating moder......一起来看看 《Learning PHP, MySQL, JavaScript, and CSS》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

html转js在线工具
html转js在线工具

html转js在线工具

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

UNIX 时间戳转换