c - 我的程序有问题吗?我似乎只得到 0.0000 作为我的答案
问题描述
#include <stdio.h>
void main (void)
{
int days, seconds;
printf("Enter the no. of days: ");
scanf("%d", &days);
seconds = days*36400;
if (days<0)
{
printf("Invalid input!");
}
else
{
printf("It is equal to %.5f seconds", seconds);
}
}
解决方案
您将 seconds 声明为整数,因此您应该更改%.5f
为%d
.
#include <stdio.h>
void main (void)
{
int days, seconds;
printf("Enter the no. of days: ");
scanf("%d", &days);
seconds = days*36400;
if (days<0)
{
printf("Invalid input!");
}
else
{
printf("It is equal to %d seconds", seconds);
}
}
推荐阅读
- nginx - 首页以“/”结尾
- angular - 在 Angular 6 中登录时显示标题链接
- laravel-5 - Laravel 分页只有第一个结果
- routing - 如何确定车辆是否从站点 m 开始,它必须返回到位置路由问题中 CPLEX 中的同一站点
- servlets - 登录后Keycloak卡在循环中
- python - Are there any differences between Python2 PriorityQueue and Python3 PriorityQueue's put method?
- javascript - Refreshing JWT token - Do it? When?
- javascript - Is there a 'neat' way to generate Javascript code?
- vhdl - 如何添加向量的位并同时将值保存在向量信号中?我用谷歌翻译**
- bash - Bash script to close multiple remote branches from text-file