C Prime Plus 第六版
第03章 数据和C 编程练习 5
编译器版本:Mac Xcode 11.6
5. 一年大约有秒。编写一个程序,提示用户输入年龄,然后显示该年龄对应的秒数
//
// main.c
// Ex05 Page 69
//
// Created by turbo on 2021/5/9.
// Copyright © 2021 LiangNuo Software Technology Co., LTD. All rights reserved.
//
/* 一年大约有3.156*10^7秒。编写一个程序,提示用户输入年龄,然后显示该年龄对应的秒数 */
#include <stdio.h>
int main(void)
{
unsigned short int ages;
printf("Please your ages: ");
scanf("%hd", &ages);
unsigned long seconds = ages * 3.156E7;
printf("your ages about %ld seconds\n", seconds);
return 0;
}
程序输出
Please your ages: 38
your ages about 1199280000 seconds
Program ended with exit code: 0