"Too few arguments to function" question

Nov 24, 2014 at 6:55pm
Hey there peoples. Got a hopefully quick and easy question for ya. Having an issue with this code. Im getting the error "In function `int main()': too few arguments to function `void printdata(int, int, float, float, float)' at this point in file". I tried looking some other place online but could not find anything I was able to grasp being a very beginner programmer. I appreciate any and all help. Thanks for your time.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

void getdata (int& length , int& width, float& costperdqfoot);
float InstalledPrice (int length, int width, float costpersquarefoot);
float totalprice (float installation);
void printdata (int length, int width, float price, float installation, float total);
const float LABOR_COST=0.35;
const float TAX_RATE=0.05;

int main()
{ 
    int length, width;
    float installation, total, costpersqfoot, price;
    
    int num;
    cout<< "Enter the amount of the count:"<<endl;
    cin>>num;
    const int MAXCOUNT = num;
    int count;
    
    for (count = 0; count < MAXCOUNT; count++)
    { 
      getdata (length, width, costpersqfoot);
      installation = InstalledPrice (length, width, costpersqfoot);
      total = totalprice (installation);
      printdata (length, width, price);
    } 
    system("pause");
    return 0;
}
void getdata (int& length, int& width, float& costpersqfoot)
{
 cout<< "Eneter the length, width, and cost per square foot"<<endl;
 cin>> length >> width >> costpersqfoot;
}    
float InstalledPrice (int length, int width, float costpersqfoot)
{
 return (length*width*costpersqfoot)+(length*width*LABOR_COST);
}
float totalprice (float installation)
{
 return (installation*TAX_RATE);
}

void printdata (int length, int width, float price, float installation, float total)
{
 cout<< "The cost for installation is: "<< installation<< endl;
 cout<< "The total cost with tax is: "<< total<< endl;
Nov 24, 2014 at 7:03pm
When you call printdata on line 30, you only pass 3/5 arguments. You have to pass it something for installation and total. Even if it's a null value you don't use.

 
printdata (length, width, price, 0, 0);
Last edited on Nov 24, 2014 at 7:04pm
Nov 24, 2014 at 7:04pm
so

in your function prototype for printdata on line 49 you declared your function to have 5 arguments (int,int,float,float,float) the same in your function definition on line 10

but in main when you call the function (line 30) you only used 3 arguments (length, width, price)

this is your problem. if you declare your function to have 5 arguments you must also put 5 arguments when you call the function
so line 30 would need to have something like (length, width, price,installation,total)

good luck
Nov 24, 2014 at 7:04pm
The error message is very clear. You are passing too few arguments to the function. You have defined printdata to take 5 arguments but you are only passing 3 arguments when you call it on line 30.
Nov 24, 2014 at 8:04pm
Oh wow thanks so much for that. Sorry such a dumb question.
Last edited on Nov 24, 2014 at 8:30pm
Topic archived. No new replies allowed.