第七章:C控制语句:分支和跳转
本章将介绍以下内容:
1、关键字——if、else、switch、continue、break、case、default、goto;
2、运算符——&&、||、?:
3、函数——getchar()、putchar()、ctype.h系列;
4、如何使用 if 和 if else 语句,如何嵌套它们;
5、在复杂的测试表达式中用逻辑运算符组合关系表达式;
6、C的条件运算符;
7、switch 语句
8、break、continue、goto语句;
9、使用C的字符I/O函数——getchar()和putchar();
10、ctype.h 头文件提供的字符分析函数系列
7.1 if 语句
1 #include<stdio.h> 2 int main(void) 3 { 4 int num; 5 printf("请输入一个整数:"); 6 scanf_s("%d", &num); 7 8 if (num > 0) 9 { 10 printf("你输入的数字%d是正数!", num); 11 } 12 if (num < 0) 13 { 14 printf("你输入的数字%d是一个负数", num); 15 } 16 return 0; 17 }

浙公网安备 33010602011771号