c语言语句
时间: 2023-08-31 15:22:55 浏览: 94
C语言控制语句
C语言中常见的语句有赋值语句、条件语句、循环语句、函数调用语句等等。以下是一些示例:
赋值语句:
```
int a = 10;
float b = 3.14;
char c = 'A';
```
条件语句:
```
if (a > 0) {
printf("a is positive");
} else if (a == 0) {
printf("a is zero");
} else {
printf("a is negative");
}
```
循环语句:
```
for (int i = 0; i < 10; i++) {
printf("%d\n", i);
}
while (a < 100) {
a *= 2;
}
```
函数调用语句:
```
int sum = add(3, 5);
printf("The sum of 3 and 5 is %d", sum);
```
阅读全文