Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Look Ma, no error handling :D
- i know what the program does
- therefore i don't need it. */
- #include <stdio.h>
- int main(void)
- {
- float kj;
- float pro;
- float car;
- float fat;
- printf("\nEnter Nutrition Data:\n\n");
- printf("Kilojoules: ");
- scanf("%f", &kj);
- printf("Fat: ");
- scanf("%f", &fat);
- printf("Protein: ");
- scanf("%f", &pro);
- printf("Carbohydrate: ");
- scanf("%f", &car);
- printf("\n");
- printf("Total Calories: %.0f\n", kj / 4.148);
- printf("Breakdown...\n\n");
- printf("Fat: \t\t%2.2f%%\n", (fat * 9)/(kj/4.148)*100);
- printf("Protein: \t%2.2f%%\n", (pro * 4)/(kj/4.148)*100);
- printf("Carbohydrate: \t%2.2f%%\n\n", (car * 4)/(kj/4.148)*100);
- }
Add Comment
Please, Sign In to add comment