6. 用scanf函数输入数据,使a=3,b=7,x=8.5,y=71.82,c1=A, c2=a,并将其依次输出。
时间: 2024-05-06 20:17:31 浏览: 89
C语言数据输入与输出实例详解
5星 · 资源好评率100%
以下是代码实现:
```c
#include <stdio.h>
int main() {
int a, b;
float x, y;
char c1, c2;
scanf("%d %d %f %f %c %c", &a, &b, &x, &y, &c1, &c2);
printf("a = %d\n", a);
printf("b = %d\n", b);
printf("x = %.1f\n", x);
printf("y = %.2f\n", y);
printf("c1 = %c\n", c1);
printf("c2 = %c\n", c2);
return 0;
}
```
输出结果如下:
```
a = 3
b = 7
x = 8.5
y = 71.82
c1 = A
c2 = a
```
阅读全文