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://www.codercto.com/courses/l/17.html

查看所有标签

An Introduction to Probability Theory and Its Applications

An Introduction to Probability Theory and Its Applications

William Feller / Wiley / 1991-1-1 / USD 120.00

Major changes in this edition include the substitution of probabilistic arguments for combinatorial artifices, and the addition of new sections on branching processes, Markov chains, and the De Moivre......一起来看看 《An Introduction to Probability Theory and Its Applications》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试