Code:

#include <stdio.h>
int main(void)
{
double metal_rod_length_cm; //length of each individual metal rod
double length; //temporary storage for normal length rods entered
int normal_count; //total count of metal rods that are exactly 10 cm long
int short_count; //total count of metal rods that are <10 cm long
int long_count; //total count of metal rods that are >10 cm long
int overall_count; //total count of normal rods, short rods, and long rods
int normal_total; //sum of lengths of all normal metal rods
int short_total; //sum of lengths of all short metal rods
int long_total; //sum of lengths of all long metal rods
int overall_total; //sum of all lengths of normal, short, and long metal rods
double normal_average; //average length of all normal metal rods
double short_average; //average length of all short metal rods
double long_average; //average length of all long metal rods
double overall_average; //sum of all averages all metal rods
printf("\nWelcome.\n");
printf("Categorize manufactured metal rods based on length in centimeters\n");
printf("and calculate averages of different categories.\n\n");
printf("Input the length (in centimeters) of each metal rod, one at a time:"); //prompt for length, in cm.
do{
scanf("lg", &metal_rod_length_cm); //keyboard input for length of metal rod
printf("%g", &metal_rod_length_cm); //screen output for length just inputted
if (metal_rod_length_cm==10)
{
++normal_count; //increases with each metal rod entered that is exactly 10 cm long
++overall_count; //increases with each metal rod measurement that is entered
normal_total += length; //adds length of all normal length metal rods
overall_total += length; //adds all metal rods entered to overall length total
}
else if (metal_rod_length_cm <10)
{
++short_count; //increases with each metal rod entered that is less than 10 cm long
++overall_count; //increases with each metal rod measurement that is entered
short_total += length; //adds length of all short length metal rods
overall_total += length; //adds all metal rods entered to overall length total
}
else (metal_rod_length_cm >10)
{
++long_count; //increases with each metal rod entered that is greater than 10 cm long
++overall_count; //increases with each metal rod measurement that is entered
long_total += length; //adds length of all long length metal rods
overall_total += length; //adds all metal rods entered to overall length total
}
}while (metal_rod_length_cm !=0); //while metal rod length entered does not equal zero
if (overall_count>20)
{
printf("Error: You do not have 20 metal rods in batch to be analyzed.");
}
else if (overall_count<20)
{
printf("Error: You do not have 20 metal rods in batch to be analyzed.");
}
if (metal_rod_length_cm=0)
{
normal_average=normal_total/normal_count;
short_average=short_total/short_count;
long_average=long_total/long_count;
overall_average=overall_total/overall_count;
}
printf("Statistics:\n");
printf("Desc\t Number\t Total:\t Average:\n");
printf("Normal\t");
printf("%i\t",normal_count);
printf("%i\t",normal_total);
printf("%g\n",normal_average);
printf("Short\t");
printf("%i\t",short_count);
printf("%i\t",short_total);
printf("%g\n",short_average);
printf("Long\t");
printf("%i\t",long_count);
printf("%i\t",long_total);
printf("%g\n",long_average);
printf("Overall\t");
printf("%i\t",overall_count);
printf("%i\t",overall_total);
printf("%g\n",overall_average);
return 0;