Hayes
10-11-2011, 12:10 PM
Im playing around with C and I am trying to exit a while loop with the letter q but i cant seem to get it to work.
/*
Program: daystoweeks.c
Author: Danny Stones
Date: 11/10/2011
*/
#include <stdio.h>
int main(){
int day;
int week;
int days;
printf("Please enter the number of days: ");
scanf("%d", &day);
while (day!='q')
{
week = day/7;
days = day % 7;
printf("%d weeks and %d days", week, days);
printf("\nPlease enter the number of days: ");
scanf("%d", &day);
}
return 0;
}
Thanks
Danny
/*
Program: daystoweeks.c
Author: Danny Stones
Date: 11/10/2011
*/
#include <stdio.h>
int main(){
int day;
int week;
int days;
printf("Please enter the number of days: ");
scanf("%d", &day);
while (day!='q')
{
week = day/7;
days = day % 7;
printf("%d weeks and %d days", week, days);
printf("\nPlease enter the number of days: ");
scanf("%d", &day);
}
return 0;
}
Thanks
Danny