Need Help

I have a problem in a class and have no way to even begin the project.
I need to implement a C++ program that asks the user for four floating-point numbers. The program shoul 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(){
int a=1;
int b=2;
int sum;

sum=::sum(a,b);
print(a,b,sum);
a = 3; // I changed these to show that the value of sum was indeed being
b = 10; // changed after the next function call
::sum(a,b,sum);

print(a,b,sum);
return 0;
}

int sum(int a1,int b2){
return a1+b2;
}

void sum(int n1,int n2,int& answer){
answer=n1 + n2;
}

void print(int v1,int v2,int sum){
cout<<v1<<"+"<<v2<<"="<<sum<<endl;
}
Last edited on
no way to even begin the project.


Please, it would take a half hour at most to read the first two chapters of the C++ tutorial (click Documentation link) on this site which would teach you how to prompt a user for four numbers and assign them to float variables. Do that much and post your code if you need help with the functions (chapter 3 BTW ;-).
Topic archived. No new replies allowed.