Any help much appreciated
I have been asked to write a program that will ask the user to enter two months, and then give the number of days from the start of the first month to the end of the second. I have very little experience with programming and i'm struggling with this one...
Please do not flame me, i am not asking anyone to do this for me, but if you could give me a push in the right direction it would be much appreciated.
The main problem i am having is trying to figure out how to do the actual working out.. The number of days in each month is to be stored in an array, numDays, am i right in thinking that i'll have to use ++ in some way? I am really stuck with this, any help at all would be great.
Here is what i have so far... It isn't even half done yet, i know that its a big mess but pls bear in mind i am a total programming n00b..
I have no idea where to put the array, i realise its probably not meant to go there....
The 'if' statement will almost certainly not work, it was a stab in the dark...
I'm sure i've either got too many variables or else they arn't defined very well...
Take pity on me?
Code:
#include <stdio.h>
int main()
{
int fromMonth, toMonth;
printf ("This program will tell you the number of days from the start of one month to the end of another\n");
printf ("Enter the nmumber of the months you wish to use (Jan=1, Feb=2 etc..): ");
scanf ("%d", &fromMonth );
scanf ("%d", &toMonth );
printf ("The total number of days is %d\n", howManyDays( fromMonth, toMonth ) );
return 0;
}
int howManyDays (int fromMonth, int toMonth)
{
if fromMonth < 1, > 12, if toMonth < 1, > 12
printf ("Error: Please check the input..\n");
howManyDays = numDays [fromMonth]
int numDays[12];
$numDays [1]=31;
$numDays [2]=28;
$numDays [3]=31;
$numDays [4]=30;
$numDays [5]=31;
$numDays [6]=30;
$numDays [7]=31;
$numDays [8]=31;
$numDays [9]=30;
$numDays [10]=31;
$numDays [11]=30;
$numDays [12]=31;