Learning by doing: Reading books and trying to understand the (code) examples
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

39 lines
457 B

#include <stdio.h>
#define DAYS_PER_WEEK 7
unsigned getDays(void);
int main (void) {
int days;
days = getDays();
while (days != 0) {
printf("%d days are %d weeks, %d days\n", days, days / DAYS_PER_WEEK, days % DAYS_PER_WEEK);
days = getDays();
}
return 0;
}
unsigned getDays(void) {
int days;
printf("Number of days (<=0 to quit): ");
if (scanf("%d", &days) != 1 || days <= 0) {
days = 0;
}
return days;
}