C Primer Plus第三章课后练习答案

其他章节答案

/*The third Unit programming answer*/
//Project 1
#include 
int main(void)
{
    int i=2147483647;
    float f=3.4E38,F=0.1234E-10;
    printf("Integer overflow:\n\ti=%d,\n\ti+1=%d;\n",i,i+1);
    printf("Float point overflow:\n\tf=%e,\n\tf*100.0F=%e;\n",f,f*100.f);
    printf("Float point underflow:\n\tF=%e,\n\tF/10=%e;\n",F,F/10);
    return 0;
}
//Project 2
#include 
int main(void)
{
    char c;
    printf("Please enter an ASCII value: ");
    scanf("%d",&c); //In the scanf function,don't please "\n" after "%d".
                    //If you want to enter numbers,use %d,otherwise,use %c.
    printf("c=%c\n",c);
    return 0;
}
//Project 3
#include 
int main(void)
{
    printf("\a");
    printf("Startled by the sudden sound,Sally shouted,\n\"By the Great Pumpkin, what was that!\"\n");
    //Note the input of "".
    return 0;
}
//Project 4
#include 
int main(void)
{
    float f=64.25;
    printf("Enter a floating-point value: ");
    scanf("\f",&f);
    printf("fixed-point notation: %f\n",f);
    printf("exponential notation: %e\n",f);
    //printf("p notation: %a\n",f); //My system does't support hexadecimal notation.
    return 0;
}
//Project 5
#include 
int main(void)
{
    int age;
    float second;
    printf("Please enter your age: ");
    scanf("%d",&age);
    second=age*3.156e7;
    printf("The second for this age: %e\n",second);
    return 0;
}
//Project 6
#include 
int main(void)
{
    int k;
    float n;
    printf("Please enter the water's quartos: ");
    scanf("%d",&k);
    n=k*950/3.0e-23;
    printf("The number of water molecules: %e\n",n);
    return 0;
}
//Project 7
#include 
int main(void)
{
    int i;
    float f;
    printf("Please enter your height:___in.\b\b\b\b\b\b");
    scanf("%d",&i);
    f=i*2.54;
    printf("your height: %.2f cm.\n",f);
    return 0;
}
//Project 8
#include 
int main(void)
{
    float b;
    printf("Enter the number of cups:____\b\b\b\b");
    scanf("%f",&b);
    printf("the pint is:%.1f.\nthe ounce is:%.1f.\nthe spoon is:%.1f.\nthe tea spoon is:%.1f.\n",b/2,b*8,b*8*2,b*8*2*3);
    return 0;
}

你可能感兴趣的:(C Primer Plus第三章课后练习答案)