屏幕输出语句_C语言输入与输出习题及答案

本文是一系列C语言输入输出习题及其答案,涉及printf和scanf函数的使用,包括浮点数格式化输出、字符输入、整数格式控制等方面。题目涵盖各种情况,如输入格式、输出格式、类型转换等,旨在帮助读者深入理解C语言的输入输出操作。
摘要由CSDN通过智能技术生成

点击蓝字

关注我们

1-1double f = 2.5e5;

printf ("f=%5.4lf\n", f);

The output will be

f=250000.0000

T

1-2int a,b;

scanf("a=%d,b=%d",&a,&b);

the correct input should be: 5,6 

 F

1-3语句printf("%.2f",1.0/3);输出为0.33。

1-4

C语言中不能用scanf 函数输入字符。

F

1-5C语言中不能用printf函数输出字符。

F

1-6执行以下程序段后,输出i = 10, j = 20。

int i, j;  
i = 10;
j = 20;
printf("i = %d, j = %d", j, i);

F

1-7执行以下程序段,输入10,输出10.00。

double x;
scanf("%d", &x);  
printf("%.2f", x);   F

1-8执行以下程序段,输入20,输出20.00。

double x;  
scanf("%f", &x);  
printf("%.2f", x);   F

1-9执行以下程序段,输入30,输出30.00。

double x;  
scanf("x=%lf", &x);  
printf("%.2f", x);   F

1-10执行以下程序段,输入1000 3 0.025,输出1000#3#0.025。

int money, year;
double rate;
scanf("%d %d %lf", &money, &year, &rate);
printf("%d#%d#%.3f", money, year, rate); T

1-11执行以下程序段,输入1001 3 0.025,输出1001#3#0.025。

int money, year;
double rate;
scanf("%d %lf %d ", &money, &year, &rate);
printf("%d#%d#%.3f", money, year, rate);

F

1-12执行以下程序段,输入1002 0.025 3,输出1002#3#0.025。

int money, year;
double rate;
scanf("%d%lf%d", &money, &rate, &year);
printf("%d#%d#%.3f", money, year, rate);  T 

1-13执行以下程序段,输入1003 3 0.025,输出1003#3#0.025。

int money, year;
double rate;
scanf("%d %d %lf", &money, &year);
printf("%d#%d#%.3f", money, year, rate);

F

1-14C语言中不能用printf函数输出字符。

F

1-15C语言中不能用scanf函数输入字符。

F

1-16执行语句putchar('S');后,在屏幕上显示的输出结果是'S'。

F

1-17设变量已正确定义,执行以下程序段,顺序输入三个字符'Q',则输出Q。 

F

ch = getchar(); 

putchar(ch);
1-18设变量已正确定义,执行以下程序段,顺序输入三个字符'k',则输出k。

T

scanf(“%c%c%c”, &ch1, &ch2, &ch3); 

printf(“%c”, ch2);
1-19若表达式sizeof(int)的值为4,则int类型数据可以表示的最大整数为231−1。 

T

1-20

下面这段代码,用%d格式打印输出double型变量,将会进行取整,输出为3。 

#include

int main(){
   double pi = 3.14159;
   printf("%d", pi);
   return 0;
}

1-21下面这段代码,用%.2f格式打印输出int型变量,将会输出2019.00。

F

#include

int main(){
   int k

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值