this is my first question on this "forum"(if you can call is that?). I started to learn how to code in C, but im stuck on a section where I am needing to use a continue and break statement within a if and if else. But it keeps giving me an error that I am unable to fix. Here is the code where I am getting the difficulties:
{
printf("\nPlease enter the total time for snail %d in seconds:", snail_numbers[0]);
scanf("%d", &snail_time);
int minutes = snail_time / 60;
int seconds = snail_time % 60;
printf("Snail %d finished in: %d minutes and %d seconds\n", snail_numbers[0], minutes, seconds);
printf("Please enter the time, in seconds, it took snail %d to complete the first quarter of the race...\n"), snail_numbers[0];
scanf("%d", &one_quarter);
printf("Please enter the time, in seconds, it took snail %d to complete the second quarter of the race...\n"), snail_numbers[0];
scanf("%d", &two_quarter);
printf("Please enter the time, in seconds, it took snail %d to complete the third quarter of the race...\n"), snail_numbers[0];
scanf("%d", &three_quarter);
printf("Please enter the time, in seconds, it took snail %d to complete the fourth quarter of the race...\n"), snail_numbers[0];
scanf("%d", &four_quarter);
/*Tells user what league the snail has qualified for*/
int total_minutes = one_quarter + two_quarter + three_quarter + four_quarter / 60;
int total_seconds = one_quarter + two_quarter + three_quarter + four_quarter % 60;
char user_confirm;
if (one_quarter + two_quarter + three_quarter + four_quarter < 241)
{
printf("%d has qualified for the International Tournament, with a total time of: %d minutes and %d seconds\n", snail_numbers[0], total_minutes, total_seconds);
}
else if (one_quarter + two_quarter + three_quarter + four_quarter < 721)
{
printf("%d has qulaified for the National Race Meeting, with a total time of: %d minutes and %d seconds\n", snail_numbers[0], total_minutes, total_seconds);
}
else
{
printf("Snail %d has qualified for the Beginner's League, with a total time of: %d minutes and %d seconds\n", snail_numbers[0], total_minutes, total_seconds);
}
{
printf("Please type 'Yes' if you would like to add more snails, or type 'No' to complete the entry of snails.\n");
scanf("%c", user_confirm);
if (user_confirm == "yes")
{
continue;
}
else if
(user_confirm == "no")
{
break;
}
}
}
It is at the bottom of this code section, any help would be greatly appreciated. :)
Aucun commentaire:
Enregistrer un commentaire