> HELP IN C PROGRAMMING?

HELP IN C PROGRAMMING?

Posted at: 2014-12-18 
here is a start:

#define FAT 9

#define PROTEIN 4

#define CARBS 4

#define ALCOHOL 7

#include

int main(void){

// put your code here

return 0;

}

1. General:

1.1. Save your code as prog1.c.

2. main:

2.1. Define named constants to be used in the calorie calculations.

2.1.1. Fat contains 9 calories per gram.

2.1.2. Protein and carbohydrates contain 4 calories per gram.

2.1.3. Alcohol contains 7 calories per gram.

2.2. Define variables.

2.3. Prompt the user separately for the grams in each category.

2.4. Calculate calories and percentages for each category using the named constants and placing the

results in variables.

2.5. Calculate total calories and percentage and place in variables.

2.6. Print the calorie table.

2.6.1. Closely follow the format in the sample shown below including blank lines.

2.6.2. Right align the numbers under the column headings without using tabs. Use the width

option in the placeholder and spaces in the format string to do the alignment.

2.6.3. Print percentage with one decimal place.

Sample Run and Output – Fiber One Oats & Chocolate Chewy Bar

[Unix Prompt]

Enter fat grams: 4

Enter protein grams: 2

Enter carbohydrate grams: 29

Enter alcohol grams: 0

Grams Calories Percent

Fat 4 36 22.5

Protein 2 8 5.0

Carbohydrates 29 116 72.5

Alcohol 0 0 0.0

TOTAL 160 100.0

[Unix Prompt]