What do I need to add to get the output to display to the user? I am not sure what printf statement I need to add to make it work. I know how to display text to the user but not how to display the results of the calculations.
#include <stdio.h>
#define NORMAL_ROD 10
#define SENTINEL 0
int main(void)
{
//Variable declarations
int normal_count = 0;
int normal_total = 0;
int long_count = 0;
int long_total = 0;
int short_count = 0;
int short_total = 0 ;
double normal_average;
double long_average;
double short_average;
double overall_average;
int overall_count =0;
int overall_total= 0;
int rodLength = 1;
printf("Rod Manufacturing Quality Control\n");
while(1)
{
printf("Input Rod Length: ");
scanf("%i", &rodLength);
if(rodLength == SENTINEL) break;
overall_count = overall_count + 1;
overall_total = overall_total + rodLength;
if(rodLength == NORMAL_ROD)
{
normal_count = normal_count + 1;
normal_total = normal_total + rodLength;
}
else if(rodLength > NORMAL_ROD)
{
long_count = long_count +1;
long_total = long_total + rodLength;
}
else
{
short_count = short_count +1;
short_total = short_total = rodLength;
}
}
// Average calcs
normal_average = (double)normal_total / normal_count;
short_average = (double)short_total / short_count;
long_average = (double)long_total / long_count;
overall_average = (double)overall_total / overall_count;
/*
...
...
...
*/
// Print output
printf("Statistics:\n");
printf("Desc Number Total Average\n");
return 0;
}
/*
Output here!
*/