Review
Practice
1.略
2.
#include
int main(void)
{
//输入一个整数
int i;
printf("Please enter the value of i: \n");
scanf("%d",&i);
printf("i = %d\n", i);
//将这个整数赋给一个字符,自动按照ascii码找到相应的字符
char
c = i;
printf("the ASCII character of number %d is
%c\n", i, c);
return 0;
}
3.
#include
#include
#include
int main(void)
{
printf("startled by the sudden sound,\a Sally
shouted, \"By the Great Pumpkin, what was that!\"\n");
printf("\a");
return 0;
}
4.
#include
int main(void)
{
float f;
printf("Please enter a float: \n");
scanf("%f", &f);
printf("f = %f and f also = %e\n", f, f);
return 0;
}
5.
#include
int main(void)
{
int i;
double one_year = 3.156e7;
printf("My master, please enter your age:
\n");
scanf("%d",&i);
printf("My master, you have been on the earth for
about %f seconds!\n", i*one_year);
return 0;
}
7.
#include
int main(void)
{
float height;
float one_inch = 2.54;
printf("Please enter your height in centimiter my
master: \n");
scanf("%f",&height);
printf("My master, you're %1.2f cm high and that
is %1.2f inch, so cool!\n", height, height/one_inch);
return 0;
}