Write a function that calculates the average of three values

Write a function that calculates the average of three values.

The function must conform to the following:

Name: find_average

Parameters:

float num1 - First number

float num2 - Second number

float num3 - Third number

Return type:

float - The average

Put this code in a file called average.cpp.

Do not include a main function.

Solution

We can write program without main function using token pasting operator.The ‘##‘ operator is called the token pasting or token merging operator.That is we can merge two or more characters with it.

#include <iostream>

#define find_average m##a##i##n
int find_average()
{
    float num1,num2,num3;
    std::cout<<\"Enter Three Numbers\";
    std::cin>>num1>>num2>>num3;
    float result;
    result=num1+num2+num3/3;
    std::cout<<\"Average of three numbers::\";
    std::cout<<result;
   
    return 0;
}

Write a function that calculates the average of three values. The function must conform to the following: Name: find_average Parameters: float num1 - First numb

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site