第二题
#include<stdio.h>
int main()
{
int input;
printf("Enter a value of char int ASCII:");
scanf("%d",&input);
printf("You input value is %d,and char is %c\n",input,input);
return 0;
}
第三题
#include<stdio.h>
int main()
{
char ch = '\a';
printf("%c",ch);
printf("Starled by the sudden sound, Sally shout, \n");
printf("\"By the Great Pumpkin, what was that!\"\n");
return 0;
}
第四题
#include<stdio.h>
int main()
{
float input;
printf("Enter a floating-point value:");
scanf("%f",&input);
printf("fixed-point notation: %f \n",input);
printf("exponential notation: %e \n",input);
printf("p notation: %a \n",input);
return 0;
}
第五题
#include<stdio.h>
#define SEC_PER_YEAR 3.156e7
int main()
{
float second,year;
printf("Enter how many years old you are:");
scanf("%f",&year);
second = year*SEC_PER_YEAR;
printf("You are: %.1f year old.\n",year);
printf("And you are %e seconds old, too.\n",second);
return 0;
}
第六题
#include<stdio.h>
#define MASS_PER_MOLE 3.0E-23
#define MASS_PER_QUART 950
int main()
{
float quart,quantify;
printf("Enter how many quart:");
scanf("%f",&quart);
quantify = quart*MASS_PER_QUART/MASS_PER_MOLE;
printf("There are %e molecule.\n",quantify);
return 0;
}
第七题
#include<stdio.h>
#define INCH_TO_CM 2.54
int main()
{
float inch,cm;
scanf("%f",&inch);
cm = inch*INCH_TO_CM;
printf("Hi ,your are %0.2f inch ,or %0.2f cm heigh\n",inch,cm);
return 0;
}
第八题
#include<stdio.h>
#define PINT_CUP 2
#define CUP_OUNCE 8
#define OUNCE_SPOON 2
#define SPOON_TEA 3
int main()
{
float pint,cup,ounce,spoon,tea_spoon;
printf("Enter how many cup:");
scanf("%f",&cup);
pint=cup/PINT_CUP;
ounce=cup*CUP_OUNCE;
spoon=ounce*OUNCE_SPOON;
tea_spoon=spoon*SPOON_TEA;
printf("%.1f cup equals %.1f pint, %.1f ounce, %.1f spoon, %.1f tea_spoon.\n",cup,pint,ounce,spoon,tea_spoon);
return 0;
}
来源:oschina
链接:https://my.oschina.net/u/4777478/blog/4718096