#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);
}
}
You declared seconds as an integer, so you should change %.5f
to %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);
}
}
There are couple of mistakes in your code
Yo can use following code to get the output you want
#include <stdio.h>
int main(void) {
int days, seconds;
printf("Enter the no. of days: ");
scanf("%d", &days);
if(days<=0){
printf("Invalid input");
}else{
seconds = days * 86400;
printf("It is equal to: %.5d Seconds", seconds);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.