C语言今日练习试题(主要练习英文阅读能力)

来源:互联网 发布:入店来源 我的淘宝 编辑:程序博客网 时间:2024/04/30 04:14
 刚刚学习C语言 ,就做了三道简单的试题,主要是练习英文阅读能力。

 

Exercise 1
Write a program to compute the area and perimeter of a rectangle with a

width of 3 inches and a height of 5 inches.

Exercise 2
Write a program that deliberately makes the following mistakes:
Prints a floating-point number using the %d conversion.
Prints an integer using the %f conversion.
Prints a character using the %d conversion

Exercise 3
使用一个枚举类型,表达:北京、上海、广州三个城市,然后输出他们的值。

 

#include <stdio.h>

/*int main(void){

 double a;
 double b;

 printf("请输入矩形的长:");
 scanf("%lf",&a);
 printf("请输入矩形的宽:");
 scanf("%lf",&b);
 printf("矩形的面积为:%lf\n",a*b);
 printf("矩形的周长为:%lf\n",(a+b)*2);

 return 0;
}*/

/*int main(void){

 double i = 123.45;
 int j = 678;
 char k = 'A';

 printf("double类型:%d\n",i);
 printf("int类型:%f\n",j);
 printf("char类型:%d\n",k);

 return 0;
}*/

/*int main(void){

 enum city{beijing,shanghai,guangzhou};

 printf("北京:%d\n",beijing);
 printf("上海:%d\n",shanghai);
 printf("广州:%d\n",guangzhou);

 return 0;
}*/

原创粉丝点击