Write a C program that uses functions. The main() method holds an integer variable named numberOfEggs to which you will assign a value. Create a method called myEggs() to which you pass numberOfEggs. The method displays the eggs in dozens; for example, 50 eggs is 4 full dozen (with 2 eggs remaining).
#include <stdio.h>
void myEggs(int eggs) {
int dozens = eggs / 12;
printf("%d eggs is %d full dozen\n", eggs, dozens);
}
int main() {
int eggs;
printf("Enter a number of eggs: ");
scanf("%d", &eggs);
if (eggs , 0) {
printf("Sorry number ahould be greater than 0\n");
return 0;
}
myEggs(eggs);
return 0;
}
Comments
Leave a comment