# Arrays and functions problems

Page 1 of 1

## 1 Replies - 99 Views - Last Post: 27 July 2012 - 08:55 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=287201&amp;s=7e941142795f42008dbe043cdb62300e&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 BarackObama

Reputation: 0
• Posts: 13
• Joined: 27-July 12

# Arrays and functions problems

Posted 27 July 2012 - 08:46 PM

Hello I'm trying read data from a file and display it into 3 arrays coloums. however I keep on getting an error on line 33 stating [expected primary-expression before "int,double,int,int"] [ISO C++ forbids declaration of `readHousehold' with no type] I cant figure it out but I know it has to do with my functions. Thank you so much!

here is the prompt

The results of a survey( in a file) of the households in your township are available for public scrutiny. Each record contains data for one household, including a four-digit integer identification number, the annual income for the household , and the number of household members ( int, double, int). Write a program to read the survey results into three arrays and perform the following analysis (irrelevant as of now).

Here's my code
[/
#include <iostream>
#include <iomanip>
#include <fstream>

using namespace std;

int readHousehold(ifstream &inFile,int idhouseholdArray[], double incomeArray[], int membersArray[], int size);
void displayhouseData(int idhouseholdArray[], double incomeArray[], int membersArray[]);

const int OK = 0;

int main()
{
int rc;

int idhouseholdArray[24] = {1041,1062,1327,1483,1900,2112,2345,3210,3600,3601,4724,6217,9280,1000,1200,5601,5724,5217,5280,5000,5200,5230,6641,7000};

double incomeArray[24] ={12180,13240,19800,22458,17000,18125,15623,3200,6500,11970,8900,10000,6200,30000,35000,51970,66900,10000,70000,100000,25000,120000,85000,45500};

int membersArray[24] ={4,3,2,8,2,7,2,3,5,2,3,2,1,3,2,9,3,2,1,6,3,6,7,4};

ifstream inFile; // create an input file object

cout << fixed
<< showpoint
<< setprecision(2);

inFile.open("Bonus-Program.txt"); // open the file read

if (!inFile.fail()) // if open was successful
{ // execute statements in true path
rc = readHousehold(inFile, int idhouseholdArray[24], double incomeArray[24], int membersArray[24], int size);
if (rc == OK)
displayhouseData(idhouseholdArray, incomeArray, membersArray);
else
cout << "Error: Incorrect house data in file!!\a" << endl;
}
else // if fail was not successful
{ // execute statements in false path
cout << "File \"bonus.txt\" "
<< endl;
}

system("PAUSE");

return 0;
}

readHousehold(ifstream &inFile,int idhouseholdArray[], double incomeArray[], int membersArray[],int size)
{
int count = 0, rtnCode = 0;
double temp;

inFile >> temp;
while ((!inFile.fail()) && (count < size))
{
idhouseholdArray[count] = temp;
count++;
incomeArray[count] = temp;
count++;
membersArray[count] = temp;
count++;

inFile >> temp;
if (count == size)
{
if (!inFile.fail())
rtnCode = 1;
}
}

if (count < size)
rtnCode = 1;

return rtnCode;
}

void displayhouseData(int idhouseholdArray[], double incomeArray[], int membersArray[]);
{

}
]

Is This A Good Question/Topic? 0

## Replies To: Arrays and functions problems

### #2 GunnerInc

• "Hurry up and wait"

Reputation: 719
• Posts: 1,978
• Joined: 28-March 11

## Re: Arrays and functions problems

Posted 27 July 2012 - 08:55 PM

Please don't open duplicate topics, it won't get you help any faster!

*** Closed ***