First, you should make sure your code is neatly formatted and indented (i.e. all code within brackets should be indented one level):
Code:
#include <stdio.h>
int main(void) /* corrected main() header */
{
int addtime,stophr,stopmin,hr=12,min=0;
printf("How many minutes do you want to add?");
scanf("%d",&addtime);
stophr=(min + addtime/60) + hr;
stopmin=(min + addtime)%60;
if(stophr>12)
{
stophr=stophr-12;
}
if(stopmin>59)
{
stopmin=stopmin-60;
}
printf("%d:%.02d\n",hr,min);
while(hr!=stophr && min!=stopmin)
{
min++;
if(hr>12)
{
hr=hr-12;
}
if(min>59)
{
hr=hr+1;
min=0;
}
printf("%d:%.02d\n",hr,min);
}
printf("%d:%.02d\n",stophr,stopmin);
}
The problem lies in your loop condition:
Code:
while(hr!=stophr && min!=stopmin)
For example, if we enter 70, then "stopmin" is set to 10. Once "min" reaches 10 the first time, the loop condition fails.
Instead of looking for the "stop hour" and "stop minute", you might consider controlling your loop with a simple counter that counts up to the maximum number of minutes.