Create a C file containing two functions (assume the main function is in another
ID: 3855032 • Letter: C
Question
Create a C file containing two functions (assume the main function is in another file). These functions should be declared within a file named 'bakingPi.c'. The functions are: 'weCanBake' parameter 1: numEggs parameter 2: numBerries return true if we have at least 12 eggs and 24 berries otherwise return false 'showResources' parameter 1: numEggs parameter 2: numBerries return nothing print out the number of eggs and berries on the console Write 'bakingPi.h' contents: Write 'bakingPi.c' contents:Explanation / Answer
The answer is as follows:
The contents of bakingPi.h is as follows:
typedef enum {
false,
true
} bool;
bool weCanBake(int numEggs, int numBerries);
void showResources(int numEggs, int numBerries);
The contents of bakingPi.c is as follows:
#include "bakingPi.h"
bool weCanBake(int numEggs, int numBerries){
if (numEggs >= 12 && numBerries >= 24)
return true;
else
return false;
}
void showResources(int numEggs, int numBerries){
printf("Number of eggs: %d Number of Berries:%d ", numEggs, numBerries);
}