要求用户输入数据并将其打印在屏幕上

要求用户输入浮点,整数并将其打印在屏幕上,以下是代码的实现:

#include <stdio.h>
int main()
{/*from  www  .yii   ba i  .  com*/
    char topping[24];
    int slices;
    int month, day, year;
    float cost;

    printf("How much does a pizza cost in your area?");
    printf("enter as $XX.XX)/n");
    scanf(" $%f", &cost);

    printf("What is your favorite one-word pizza topping?/n");
    scanf(" %s", topping);
    printf("How many slices of %s pizza", topping);
    printf("can you eat in one sitting?/n");
    scanf(" %d", &slices);

    printf("What is today/'s date (enter it in XX/XX/XX format)./n");
    scanf(" %d/%d/%d", &month, &day, &year);
    printf("/nWhy not treat yourself to dinner on %d/%d/%d", month, day, year);
    printf("/nand have %d slices of %s pizza!/n", slices, topping);
    printf("It will only cost you $%.2f!/n/n/n", cost);

    return (0);
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266389.html

(0)
上一篇 2022年6月7日
下一篇 2022年6月7日

相关推荐

发表回复

登录后才能评论