Use a value returning function

94 views 9:48 am 0 Comments March 31, 2023
    • Declare 5 integers inmain

      (

      )

      .

 

    • Prompt for and read five integer marks inmain

      (

      )

      .

 

    • Write and use a value returning function with five integer parameters to calculate and return the average to the calling function,main

      (

      )

      .
      Here is a partial prototype for you to use:

      
      
      
      
      
      avg
      
      
      (
      
      
      int
      
      
      ,
      
      
      int
      
      
      ,
      
      
      int
      
      
      ,
      
      
      int
      
      
      ,
      
      
      int
      
      
      )
      
      
      ;
      
      
      
      
      
      

      Be sure the calculation in the function produces decimal places for a more precise average. You must determine a return type that will preserve those decimal places.

 

    • Print the average in themain

      (

      )

      function.

 

    • Compile and run the C++ program.

 

  • Test the program with an input guaranteed to produce decimal places. For example:
    
    
    Please enter
    
    5
    
    
    integer marks:
    
    
    1
    
    
    2
    
    
    1
    
    
    1
    
    
    1
    
    
    The average of those marks is:
    
    
    1.2