Hello, and welcome. We got another challenge for you.
So we talked about operators in pretty good detail.
Now i want you to make sure you understand these by giving you a challenge,
trying to use some of these concepts that we've learned about.
So I want you to write a program
and I want you to create a c program that basically does some conversion.
Converting number of minutes to days and years. Now this program doesn't necessarily
seem that useful.
You may never know why you'd ever do that but
it will force you to use some of the operators mainly the arithmetic operators
and get you acquainted with those, so that's why I'm giving you this challenge.
This is a very, very simple program.
It should ask the user to enter the number of minutes via the terminal. So this is also your first challenge
where you're going to use the scanf function.
I want you to actually ask the user to enter
number of minutes. They're going to enter the number of minutes,
and then you're going to provide as output the equivalent of those minutes in years and days.
Now it gets tricky because these are all going to be doubles.
So the conversions are going to actually or
the results are going to be decimal numbers,
where you have um floating point numbers because a lot of times
you might enter 50 minutes. Well, how is 50 minutes equivalent in
years and days. Well, it's 0.0000 or something because years and
days are much larger than minutes.
So it's not a necessarily useful program,
it's not necessarily a complex program. You're going to just do some calculations.
But again, it's going to get you familiar with the basics of operators,
mainly arithmetic operators and also allow you to perform a calculation.
And then the other good thing here to learn is the scanf.
So you're going to need to create some variables to store.
They all should be type double because this is going to be very precise program.
Minutes can actually be an integer if you want, but the rest should really be doubles.
You see here that minutes needs to be available that's what you're going
to do your scanf function what you read in from the keyboard.
Minutes and year, this is necessary because
this is how you're going to do your conversion. So you need the minutes and year.
And the reason that you can use the minutes in the year to actually calculate
the number of years because the user is just going to enter the minutes.
You need to know how many minutes are in a year to display the number of years.
So I would expect you to have a variable called minutes and year.
That would be something like
the number of minutes in an hour, which is 60,
times the number of hours in a day,
which is 24. Times the number of days in a year,
which is 365. If you do 60 times 24 times
365, that's going to give you the minutes in the year.
You can then use the minutes and year and divide it by the
minutes entered by the user
and that will give you the number of years.
So it's a little more complicated than you think. Again, you're going to need to figure out this calculation.
I'm not going to give you any hints on the exact calculation. I probably gave you too much already.
But what I expect to see is output is this conversion.
So you need to perform a calculation using all the arithmetic operators.
You have to figure out the conversions.
I'm going to implement this, but I would expect
something very similar, creating some variables, using the actual
scanf function to read an input into a variable
and then assigning those variables some calculations.
I think you'll need to use
the division, multiplication operators
as well as the modulus operator for days, I would think.
Good luck. Thank you.