c primer plus 第六版 第三章编程练习

(编译环境 Microsoft Visual Studio 2019)

1.

/*1.*/
#include<stdio.h>
#include<limits.h>
int main(void)
{
    int i_toobig= 3147483647;
    float f_toobig = 3.4e38f * 100.0f;
    float f_toosmall = 3.5e-40f;

    printf("toobig int : %d\n", i_toobig);
    printf("toobig float : %f\n", f_toobig);
    printf("toosmall float : %f\n", f_toosmall);

    return 0;
}

2.

/*2.*/
#include<stdio.h>
int main(void)
{
    char character;

    printf("Please enter an ASCII code value.\n");
    scanf_s("%hhd", &character);
    printf("character: %c\n", character);

    return 0;
}

3.

/*3.*/
#include<stdio.h>
int main(void)
{
    printf("\aStartled by the sudden sound,Sally shouted,\n");
    printf("\"By the Great Pumpkin,what was that!\"\n");

    return 0;
}

4.

/*4.*/
#include<stdio.h>
int main(void)
{
    float value;

    printf("Enter a floating-point value: ");;
    scanf_s("%f", &value);

    printf("fixed-point notationn: %.6f\n",value);
    printf("exponential notation: %.6e\n",value);
    printf("p notation: %.2a\n",value);

    return 0;
}

5.

/*5.*/
#include<stdio.h>
int main(void)
{
    unsigned short age;
    float seconds;

    printf("Pleasee enter your age.\n");
    scanf_s("%hu", &age);
    seconds = age * 3.156e7f;
    printf("seconds=%e\n", seconds);

    return 0;
}

6.

/*6.*/
#include<stdio.h>
int main(void)
{
    float quarter, number;

    printf("Please enter the quarter number of water.\n");
    scanf_s("%f", &quarter);
    number = (quarter * 950) / 3.0e-23f;
    printf("%f quarter of water has %e water molecules.\n", quarter, number);

    return 0;
}

7.

/*7.*/
#include<stdio.h>
int main(void)
{
    float inch;

    printf("Please enter your height in inch.\n");
    scanf_s("%f", &inch);
    printf("Your height is %.2f in centimeter.\n", inch * 25.4f);

    return 0;
}

8.

/*8.*/
#include<stdio.h>
int main(void)
{
    float cups;

    printf("Please enter the cups.\n");
    scanf_s("%f", &cups);

    printf("pint: %.2f\n", cups / 2);
    printf("ounce: %.2f\n", cups * 8);
    printf("spoon: %.2f\n", cups * 2);
    printf("teaspoon: %.2f\n", cups * 3);

    return 0;
}

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值