【C Primer Plus第三章课后编程题】
水平有限
3.2
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int ch;
printf("Please enter a number:");
scanf("%d",&ch);
printf("%c\n",ch);
system("Pause");
return 0;
}
3.3
#include<stdio.h>
#include<stdlib.h>
int main (void)
{
printf("\aStartled by the sudden sound, Sally shouted\n");
printf("\"By the Great Pumpkin,what was that!\"");
system("Pause");
return 0;
}
3.4
#include<stdio.h>
#include<stdlib.h>
int main (void)
{
float num;
printf("Enter a floating-point value:");
scanf("%f",&num);
printf("fixed-point notation:%f\n",num);
printf("exponential notation:%e\n",num);
printf("p notation:%#a",num);
system("Pause");
return 0;
}
3.5
#include<stdio.h>
#include<stdlib.h>
int main (void)
{
int age;
printf("Please enter your age:");
scanf("%d",&age);
printf("%f",age*3.156e7);
system("Pause");
return 0;
}
3.6
#include<stdio.h>
#include<stdlib.h>
int main (void)
{
int cnt;
printf("Please enter the quaty of water.\n");
scanf("%d",&cnt);
printf("%f",cnt*950/3.0e-23);
system("Pause");
return 0;
}
3.7
#include<stdio.h>
#include<stdlib.h>
int main (void)
{
float height;
printf("Please enter your height:");
scanf("%f",&height);
printf("Your height is %fcm",height*2.54);
system("Pause");
return 0;
}
3.8
#include<stdio.h>
#include<stdlib.h>
int main (void)
{
float bottle;
printf("Please enter the number of bottles:");
scanf("%f",&bottle);
printf("%f %f %f %f",bottle/2,bottle*8,bottle*8*2,bottle*8*2*3);
system("Pause");
return 0;
}