Language: C Programming // produce result: Pancakes consumed: 211.600 Pancakes p
ID: 3744955 • Letter: L
Question
Language: C Programming
// produce result:
Pancakes consumed: 211.600
Pancakes per minute: 9.200
Minutes spent munching: 23.000
Hooray! (This will print even if you're not getting the correct results.)
void print_pancake_data(double pancake_count, double pancakes_per_minute, double minutes);
int main(void)
{
print_pancake_data(0, 9.2, 23.0);
printf(" ");
print_pancake_data(211.6, 0, 23.0);
printf(" ");
print_pancake_data(211.6, 9.2, 0);
printf(" ");
printf("Hooray! (This will print even if you're not getting the correct results.) ");
return 0;
}
Explanation / Answer
#include void print_pancake_data(double pancake_count, double pancakes_per_minute, double minutes) { if(pancake_count == 0) { printf("Pancakes consumed: %.3lf", pancakes_per_minute*minutes); } else if(pancakes_per_minute == 0) { printf("Pancakes per minute: %.3lf", pancake_count/minutes); } else { printf("Minutes spent munching: %.3lf", pancake_count/pancakes_per_minute); } } int main(void) { print_pancake_data(0, 9.2, 23.0); printf(" "); print_pancake_data(211.6, 0, 23.0); printf(" "); print_pancake_data(211.6, 9.2, 0); printf(" "); printf("Hooray! (This will print even if you're not getting the correct results.) "); return 0; }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.