Language: C Programming // produce result: Hooray! double get_pancake_data(doubl
ID: 3745010 • Letter: L
Question
Language: C Programming
// produce result:
Hooray!
double get_pancake_data(double pancake_count, double pancakes_per_minute, double minutes);
int main(void)
{
if (get_pancake_data(0, 9.2, 23.0) != 211.6)
{
printf("Failed first call to get_pancake_data(). Womp womp. :( ");
return 0;
}
if (get_pancake_data(211.6, 0, 23.0) != 9.2)
{
printf("Failed second call to get_pancake_data(). Womp womp. :( ");
return 0;
}
if (get_pancake_data(211.6, 9.2, 0) != 23.0)
{
printf("Failed third call to get_pancake_data(). Womp womp. :( ");
return 0;
}
printf("Hooray! ");
return 0;
}
Explanation / Answer
#include double get_pancake_data(double pancake_count, double pancakes_per_minute, double minutes) { if(pancake_count == 0) { return pancakes_per_minute*minutes; } else if(pancakes_per_minute == 0) { return pancake_count/minutes; } else { return pancake_count/pancakes_per_minute; } } int main(void) { if (get_pancake_data(0, 9.2, 23.0) != 211.6) { printf("Failed first call to get_pancake_data(). Womp womp. :( "); return 0; } if (get_pancake_data(211.6, 0, 23.0) != 9.2) { printf("Failed second call to get_pancake_data(). Womp womp. :( "); return 0; } if (get_pancake_data(211.6, 9.2, 0) != 23.0) { printf("Failed third call to get_pancake_data(). Womp womp. :( "); return 0; } printf("Hooray! "); return 0; }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.