step 1 define the program headers and the


Step 1 Define the program headers and the variables 
 
  #include
  #include
  #include
  #include
void main()
  {
 
    char prompt;
    float a,b,c,d,e;
    float average,total;
 
Step 2 Request the numbers from the user by input
 
    printf("Enter in five numbers \n\r");
    scanf("%f",&a);
    scanf("%f",&b);
    scanf("%f",&c);
    scanf("%f",&d);
    scanf("%f",&e);
  
Step 3 Calculate the Sum of A,B,C,D,E
 
    total=a+b+c+d+e;
 
Step 4 Compute the average
 
    average= total/5;
 
Step 5 Display the results and Stop the program
  
    printf(" The average is %f \n\r",average); 
    printf("Press any key to exit \n\r");
    scanf("\n%c",&prompt);
 
    }

The total program is as follows
 
  #include
  #include
  #include
  #include
void main()
  {
    char prompt;  
    float a,b,c,d,e;
    float average,total;
    printf("Enter in five numbers \n\r");
    scanf("%f",&a);
    scanf("%f",&b);
    scanf("%f",&c);
    scanf("%f",&d);
    scanf("%f",&e);
    total=a+b+c+d+e;
    average= total/5.0;
    printf(" The average is %f \n\r",average); 
    printf("Press any key to exit \n\r");
    scanf("\n%c",&prompt);
 
  }
 
We could replace the following two lines 
 
    total=a+b+c+d+e;
    average= total/5.0;
with 
    average =(a+b+c+d+e)/5.0;
 
Hence the program becomes 
  #include
  #include
  #include
  #include
void main()
  {
    char prompt;
    float a,b,c,d,e;
    float average;
    printf("Enter in five numbers \n\r");
    scanf("%f",&a);
    scanf("%f",&b);
    scanf("%f",&c);
    scanf("%f",&d);
    scanf("%f",&e);
    average =(a+b+c+d+e)/5.0;
    printf(" The average is %f \n\r",average);   
    printf("Press any key to exit \n\r");
    scanf("\n%c",&prompt);
}

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: step 1 define the program headers and the
Reference No:- TGS0414639

Expected delivery within 24 Hours