I need to implement a C++ program that asks the user for four floating-point numbers. The program should then calculate the average using two different functions, one value returning and one void. The program should output the average of the four numbers. For this program I need to use float instead of int for the types of variables. Can anyone help me with this? Below is a proto-type code that I am able to use to do this program.
#include <iostream>
using namespace std;
int sum(int,int);
void sum(int,int,int&);
void print(int,int,int); // <- this is the function prototype for print
int main(){
float a,b,c,d,sum,avg;
std::cout<<"Inpute your numbers:"<<endl;
std::cin>>a>>b>>c>>d;
Thank you so much for the help. I appreciate your time and knowledge.
I did code something close to this but could not get it to compile. I see now where I may have gone wrong. I will try this code and hope it works cause I have to see my instructure tomorrow. Thanks again.
No problem. This one works, though I think you get a warning which can be ignored. Only way to be sure is to test the data and expect what you should expect. Other than that, good luck with everything.