I am new to C and learning it for my University course. I am learning about functions and have to create a function that doesn't have any printf
or scanf
in it, just a function that calculates how many days are in a week.
int main(days)
{
int weeks;
printf("\nPlease enter a number of weeks: ");
scanf("%i", &weeks);
weekstodays(weeks);
printf("\nThere are %i days in %i weeks.\n", days, weeks);
return 0;
}
int weekstodays(weeks){
int days;
days = weeks * 7;
printf("%i", days);
return(days);
}
Whenever I build and run this, the main
function outputs 1 day, but the weekstodays
function outputs the desired result. (The printf
in the weekstodays
function is just to see the value of days
)
Does anyone know why the weekstodays
function is not returning the day
variable correctly?