Assume a=10, b=23.5, please solve a+b, a-b, a*b, a/b? Assume: a=3,b=4,c=5, please solve a==b!=c and a!=b==c 用C语言写出来
时间: 2024-06-14 20:06:56 浏览: 140
A+B+C问题(C语言)
5星 · 资源好评率100%
以下是使用C语言解决这些问题的代码示例:
1. 解决a+b, a-b, a*b, a/b:
```c
#include <stdio.h>
int main() {
int a = 10;
float b = 23.5;
printf("a + b = %f\n", a + b);
printf("a - b = %f\n", a - b);
printf("a * b = %f\n", a * b);
printf("a / b = %f\n", a / b);
return 0;
}
```
2. 解决a==b!=c和a!=b==c:
```c
#include <stdio.h>
int main() {
int a = 3;
int b = 4;
int c = 5;
if (a == b && b != c) {
printf("a == b != c\n");
} else if (a != b && b == c) {
printf("a != b == c\n");
} else {
printf("Neither a == b != c nor a != b == c\n");
}
return 0;
}
```
阅读全文