average of two decimal numbers

Jun 7, 2012 at 7:52pm
how do I Write a C++ program that finds the

average of two decimal numbers input
Jun 7, 2012 at 8:53pm
If you're having trouble, ask a specific question that you don't understand.
Or at least attempt to write the program. We, then, can look at your errors and tell you want you need to reread.

You came to the wrong place if you expected someone to do your homework for you.
Jun 8, 2012 at 1:49am
cout<<"Processing data...\n";
inData>>gender>>gpa;
count++;
while(!inData.eof()){
sum_gpa += gpa;
inData>>gender>>gpa;
count++;
}

average_gpa = sum_gpa / count;
cout<

something like that?
Jun 8, 2012 at 7:40am
Simply, no. Not like that. That looks like you copied some random code. As I said, you seem like you need the practice, so I won't give you the answer, but you're code will look something like this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
using namespace std;

int main()
{
     // make some variable, i.e, double num1 = 0.0;
     
     std::cout « "Enter two number: ";
     // user inputs go here
     // look up the cin object

     // calculation avg = (num1 + num2) / 2
     // display average 

     return 0;
}
Last edited on Jun 8, 2012 at 7:41am
Jun 8, 2012 at 9:31am
It looks as if they're inputting from a file, or trying to atleast, it's hard to tell without the entire code.
Topic archived. No new replies allowed.