need help with my seconds converter!

hello, i am relatively new to c++ and programming in general and my professor is very vague and often gets side tracked during lecture so i dont really learn anything in class. i have to resort to the internet for answers. my professor gave us an assignment to create a program that converts seconds into units of days hours minutes and seconds. he wants the output to be:
" the equivalent time for 121 seconds is:
2 minutes
1 second"
but my output prints
"the equivalent time for 121 seconds is:
0 days
0 hours
2 minutes
1 seconds"

my question is how do i produce my output so that it doesnt show the value if it equals 0. and also i would prefer my value to be singular when the answer is 1. for example "1 hour" instead of "1 hours"

this is what i have so far
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  #include <iostream>

int main()
{
using namespace std;
const int hours_per_day = 24;
const int mins_per_hour = 60;
const int secs_per_min = 60;

long enter_seconds;
cout<< "enter number of seconds" << endl;
cin >> enter_seconds;

long seconds = enter_seconds % secs_per_min;
long minutes = enter_seconds / secs_per_min % mins_per_hour;
long hours = enter_seconds / secs_per_min / mins_per_hour % hours_per_day;
long days = enter_seconds / secs_per_min / mins_per_hour / hours_per_day;


	cout << " The equivalent time for " << enter_seconds << " seconds is "<< endl;
	cout  << days << " days, " << endl;
	cout << hours << " hours " << endl;
	cout   << minutes << " minutes, " << endl;
	cout  << seconds << " seconds " << endl;


system ("pause");
return 0;
}
doesnt show the value if it equals 0

The answer is within the question, but lets turn it the other way: "show, if larger than 0".

Have you used the if-clause?

The 's' can be use the if too, or the ternary operator:
cout << ( (1 < days) ? "s," : ',' );
ahh you're right. but i just don't know how to write it in code. No i haven't used the if-clause yet. how does it work?
thank you! i appreciate the quick response
Topic archived. No new replies allowed.