I am a newbie to c++... Today I was handed a assignment on "array"...While working on this...I've met plenty of errors... I wonder where did my steps gone wrong...
May anyone out there borrow me a helping hand??

#include <iostream>
#include <iomanip>
using namespace std;
float calpricetopay(int[5],float[5]);  // function declaration for price to pay.
float caldiscountprice(float[5],float[5]);  // function declaration for discounted price.
float calpriceafterdiscount(float[5],float[5]);  //function declaration for Price after Discount
int main()
{
 int stocknumber[5],quantity[5],count=1,backwardcount=2,i;
 float price[5],discount[5],discountprice[5],pricetopay[5],priceafterdiscount[5];
 cout.setf (ios::fixed);
 cout.setf (ios::showpoint);
 cout.precision (2);
 for (i=1,i<=5,i++)
 {
 
   while (count<=3)
 {
  cout<<"Please enter the stock number."<<endl;
     cin>>stocknumber[i];
  if ((stocknumber>=1) && (stocknumber<=9999))
   break;
  if ((stocknumber<=0) || (stocknumber>=10000))
   cout<<"The number you entered is invalid. Please reenter another stock number."<<endl;
            cout<<"You have"<<setw(2)<<backwardcount<<setw(2)<<" chance(s) left"<<endl;
   backwardcount--;
   count++;
 }
 if (count==4)
 {
  cout<<"Sorry, you have exceeded 3 times of input."<<endl;
  cout<<"Please restart the program or contact us for further services."<<endl;
  exit(1);
 }
 }
 for (i=1,i<=5,i++)
 {
 cout<<"Please insert the price of the product."<<endl;
     cin>>price[i];
 }
 for (i=1,i<=5,i++)
 {
 cout<<"Please enter the quantity."<<endl;
 cin>>quantity[i];
 }
 
    for (i=1,i<=5,i++)
   if ((stocknumber[i]>=1) && (stocknumber[i]<=3000))
   {
    discount[i]=0;
   }
 else if ((stocknumber[i]>=3001) && (stocknumber[i]<=5000))
 {
  discount[i]=float(10)/100;
 }
 else if ((stocknumber[i]>=5001) && (stocknumber[i]<=8000))
 {
  discount[i]=float(15)/100;
 }
 else if ((stocknumber[i]>=8001) && (stocknumber[i]<=9999))
 {
  discount[i]=float(20)/100;
 }
 for (i=1,i<=5,i++)
 {
 pricetopay[i]=calpricetopay(quantity[i],price[i]);
 discountprice[i]=caldiscountprice (discount[i],pricetopay[i]);
 priceafterdiscount[i]=calpriceafterdiscount(pricetopay[i],discountprice[i]);
 cout<<"Price to pay="<<pricetopay[i]<<endl;
 cout<<"The price of the item after discount="<<priceafterdiscount[i]<<endl;
 }
 
 
 

  return 0;
}
float calpricetopay (int quantity[i], float price[i])
{
 for (i=1,i<=5,i++)
 {
  float pricetopay[i];
 pricetopay[i]=float(quantity[i])*price[i];
 return pricetopay[i];
 }
}
float caldiscountprice (float discount[i], float pricetopay[i])
{
 float discountprice[i];
 for (i=1,i<=5,i++)
 {
 discountprice[i]=discount[i]*pricetopay[i];
 
 return discountprice[i];
 }
}
float calpriceafterdiscount(float pricetopay[i], float discountprice[i])
{
 float priceafterdiscount[i];
 for (i=1,i<=5,i++)
 {
 priceafterdiscount[i]=pricetopay[i]-discountprice[i];
 return priceafterdiscount[i];
 }
}

I managed to reduce quite a number from the previous one....
I have beeen facing this for more than 3 hours...
nid help~~!!

#include <iostream>
#include <iomanip>
using namespace std;
float calpricetopay(int[],float[]);  // function declaration for price to pay.
float caldiscountprice(float[],float[]);  // function declaration for discounted price.
float calpriceafterdiscount(float[],float[]);  //function declaration for Price after Discount
int main()
{
 int stocknumber[5],quantity[5],count=1,backwardcount=2,i;
 float price[5],discount[5],discountprice[5],pricetopay[5],priceafterdiscount[5];
 cout.setf (ios::fixed);
 cout.setf (ios::showpoint);
 cout.precision (2);
 for (i=1,i<=5,i++)
 {
 
   while (count<=3)
 {
  cout<<"Please enter the stock number."<<endl;
     cin>>stocknumber[i];
  if ((stocknumber>=1) && (stocknumber<=9999))
   break;
  if ((stocknumber<=0) || (stocknumber>=10000))
   cout<<"The number you entered is invalid. Please reenter another stock number."<<endl;
            cout<<"You have"<<setw(2)<<backwardcount<<setw(2)<<" chance(s) left"<<endl;
   backwardcount--;
   count++;
 }
 if (count==4)
 {
  cout<<"Sorry, you have exceeded 3 times of input."<<endl;
  cout<<"Please restart the program or contact us for further services."<<endl;
  exit(1);
 }
 }
 for (i=1,i<=5,i++)
 {
 cout<<"Please insert the price of the product."<<endl;
     cin>>price[i];
 cout<<"Please enter the quantity."<<endl;
 cin>>quantity[i];
 }
 
    for (i=1,i<=5,i++)
 {
  if ((stocknumber[i]>=1) && (stocknumber[i]<=3000))
   
    discount[i]=0;
   
 else if ((stocknumber[i]>=3001) && (stocknumber[i]<=5000))
 
  discount[i]=float(10)/100;
 
 else if ((stocknumber[i]>=5001) && (stocknumber[i]<=8000))
 
  discount[i]=float(15)/100;
 
 else if ((stocknumber[i]>=8001) && (stocknumber[i]<=9999))
 
  discount[i]=float(20)/100;
 }
 
 for (i=1,i<=5,i++)
 {
 pricetopay[i]=calpricetopay(quantity[i],price[i]);
 discountprice[i]=caldiscountprice (discount[i],pricetopay[i]);
 priceafterdiscount[i]=calpriceafterdiscount(pricetopay[i],discountprice[i]);
 cout<<"Price to pay="<<pricetopay[i]<<endl;
 cout<<"The price of the item after discount="<<priceafterdiscount[i]<<endl;
 }
 
 
 

  return 0;
}
float calpricetopay (int quantity[], float price[])
{
 int i;
 for (i=1,i<=5,i++)
 {
  float pricetopay[5];
 pricetopay[i]=float(quantity[i])*price[i];
 return pricetopay[i];
 }
}
float caldiscountprice (float discount[], float pricetopay[])
{
 int i;
 float discountprice[5];
 for (i=1,i<=5,i++)
 {
 discountprice[i]=discount[i]*pricetopay[i];
 
 return discountprice[i];
 }
}
float calpriceafterdiscount(float pricetopay[], float discountprice[])
{
 int i;
 float priceafterdiscount[5];
 for (i=1,i<=5,i++)
 {
 priceafterdiscount[i]=pricetopay[i]-discountprice[i];
 return priceafterdiscount[i];
 }
}

We're willing to help, but you'll have to share at least the first couple errors with us. Without them, we don't really have any idea where to start looking.

At first blush, I suspect you are getting lots of errors related to array boundaries/limits. You need to remember that arrays start at element (0) not element (1). For example, int myArray[5] = {0,0,0,0,0}; produces:

myArray[0] = 0;
myArray[1] = 0;
myArray[2] = 0;
myArray[3] = 0;
myArray[4] = 0;

There is no element called myArray[5] , any attempt to access this element will cause issues.

In short, an array's elements are [0, (SIZE-1)].

the highlighted part below...
the error was "unable to convert parameter"
may i know what does it mean?
and regarding fbody's previous reply, is the correction done in the code below?
Thanks

#include <iostream>
#include <iomanip>
using namespace std;
float calpricetopay(int[],float[]);  // function declaration for price to pay.
float caldiscountprice(float[],float[]);  // function declaration for discounted price.
float calpriceafterdiscount(float[],float[]);  //function declaration for Price after Discount
int main()
{
 int stocknumber[5],quantity[5],count=1,backwardcount=2,i;
 float price[5],discount[5],discountprice[5],pricetopay[5],priceafterdiscount[5];
 cout.setf (ios::fixed);
 cout.setf (ios::showpoint);
 cout.precision (2);
 for (i=0,i<=4,i++)
 {
 
   while (count<=3)
 {
  cout<<"Please enter the stock number."<<endl;
     cin>>stocknumber[i];
  if ((stocknumber>=1) && (stocknumber<=9999))
   break;
  if ((stocknumber<=0) || (stocknumber>=10000))
   cout<<"The number you entered is invalid. Please reenter another stock number."<<endl;
            cout<<"You have"<<setw(2)<<backwardcount<<setw(2)<<" chance(s) left"<<endl;
   backwardcount--;
   count++;
 }
 if (count==4)
 {
  cout<<"Sorry, you have exceeded 3 times of input."<<endl;
  cout<<"Please restart the program or contact us for further services."<<endl;
  exit(1);
 }
 }
 for (i=1,i<=5,i++)
 {
 cout<<"Please insert the price of the product."<<endl;
     cin>>price[i];
 cout<<"Please enter the quantity."<<endl;
 cin>>quantity[i];
 }
 
    for (i=0,i<=4,i++)
 {
  if ((stocknumber[i]>=1) && (stocknumber[i]<=3000))
   
    discount[i]=0;
   
 else if ((stocknumber[i]>=3001) && (stocknumber[i]<=5000))
 
  discount[i]=float(10)/100;
 
 else if ((stocknumber[i]>=5001) && (stocknumber[i]<=8000))
 
  discount[i]=float(15)/100;
 
 else if ((stocknumber[i]>=8001) && (stocknumber[i]<=9999))
 
  discount[i]=float(20)/100;
 }
 
 for (i=0,i<=4,i++)
 {
 pricetopay[i]=calpricetopay(quantity[i],price[i]);
 discountprice[i]=caldiscountprice (discount[i],pricetopay[i]);
 priceafterdiscount[i]=calpriceafterdiscount(pricetopay[i],discountprice[i]);
 cout<<"Price to pay="<<pricetopay[i]<<endl;
 cout<<"The price of the item after discount="<<priceafterdiscount[i]<<endl;
 }
 
 
 

  return 0;
}
float calpricetopay (int quantity[], float price[])
{
 int i;
 for (i=0,i<=4,i++)
 {
  float pricetopay[5];
 pricetopay[i]=float(quantity[i])*price[i];
 return pricetopay[i];
 }
}
float caldiscountprice (float discount[], float pricetopay[])
{
 int i;
 float discountprice[5];
 for (i=0,i<=4,i++)
 {
 discountprice[i]=discount[i]*pricetopay[i];
 
 return discountprice[i];
 }
}
float calpriceafterdiscount(float pricetopay[], float discountprice[])
{
 int i;
 float priceafterdiscount[5];
 for (i=0,i<=4,i++)
 {
 priceafterdiscount[i]=pricetopay[i]-discountprice[i];
 return priceafterdiscount[i];
 }
}
for (i=0,i<=4,i++)
 {
 pricetopay[i]=calpricetopay(quantity[i],price[i]);
 discountprice[i]=caldiscountprice (discount[i],pricetopay[i]);
 priceafterdiscount[i]=calpriceafterdiscount(pricetopay[i],discountprice[i]);
 cout<<"Price to pay="<<pricetopay[i]<<endl;
 cout<<"The price of the item after discount="<<priceafterdiscount[i]<<endl;
 }

This one is correct...

This one is not...

for (i=1,i<=5,i++)
 {
 cout<<"Please insert the price of the product."<<endl;
     cin>>price[i];
 cout<<"Please enter the quantity."<<endl;
 cin>>quantity[i];
 }

You are getting the parameter error because you are sending a specific array element as an argurment rather that the complete array. You will have to change your calling statement to send the array itself, or change your function definition to only accept a single value rather than an array of values. Based on your function definitions, I would recommend changing your calling statements.

use the code tag while posting the source code

when using for loop u must use semi colon ";"

do not use commas ","

i should be like

for (int i=0; i<10; i++)

and in first if condition stocknumber shoud be specified with array index value like this

if ((stocknumber[i]>=1) && (stocknumber[i]<=9999))

and on line 68, 69 inside the for condition

for (i=1;i<=5;i++)
{
pricetopay[i]=calpricetopay(quantity[i],price[i]);
discountprice[i]=caldiscountprice (discount[i],pricetopay[i]);
priceafterdiscount[i]=calpriceafterdiscount(pricetopay[i],discountprice[i]);
cout<<"Price to pay="<<pricetopay[i]<<endl;
cout<<"The price of the item after discount="<<priceafterdiscount[i]<<endl;
}

here u are trying to convert different datatypes which is not possible.

and in many places u have used variable " i " for the loops and conditions some of them are not declared, u have to declare a new variable or initialize the i every time u use it inside the loop or condition

try to code a single function at a time and see if that executes properly. and then proceed to the next function.

Hope this helps ya

"i" is declared as an int at the beginning of main() and initialized as part of each for loop, so that's not an issue. The first parameter is an "initialization" statement, not necessarily a declaration statement, you don't have to declare your iteration variable there, or use the statement at all for that matter. The issue is the value of the initialization and the range used. I'll admit though, I didn't notice the comma vs. semi-colon thing.

Thanks for your advices =)
I have managed to make it to 0 errors...
But my output still doesnt giv me the values for discount price and price after discount..

#include <iostream>
#include <iomanip>
using namespace std;
float calpricetopay(int[],float[]);  // function declaration for price to pay.
float caldiscountprice(float[],float[]);  // function declaration for discounted price.
float calpriceafterdiscount(float[],float[]);  //function declaration for Price after Discount
int main()
{
 int stocknumber[5],quantity[5],count=1,backwardcount=2,i;
 float price[5],discount[5],discountprice[5],pricetopay[5],priceafterdiscount[5];
 cout.setf (ios::fixed);
 cout.setf (ios::showpoint);
 cout.precision (2);
 
    for (i=0;i<5;i++)
 {
  do
   {
   
   
     cout<<"Please enter the stock number."<<endl;
      
 
          cin>>stocknumber[i];
   
    
    
  if ((stocknumber[i]>=1) && (stocknumber[i]<=9999))
   break;
  if ((stocknumber[i]<=0) || (stocknumber[i]>=10000))
   cout<<"The number you entered is invalid. Please reenter another stock number."<<endl;
            cout<<"You have"<<setw(2)<<backwardcount<<setw(2)<<" chance(s) left"<<endl;
   backwardcount--;
   count++;
       
   }while (count<=3);
 
 if (count==4)
 {
  cout<<"Sorry, you have exceeded 3 times of input."<<endl;
  cout<<"Please restart the program or contact us for further services."<<endl;
  exit(1);
 }
 }
 
 
 for (i=0;i<5;i++)
 {
 cout<<"Please insert the price of the product."<<endl;
     cin>>price[i];
 cout<<"Please enter the quantity."<<endl;
 cin>>quantity[i];
 }
  
 
    for (i=0;i<5;i++)
 {
  if ((stocknumber[i]>=1) && (stocknumber[i]<=3000))
   
    discount[i]=0;
   
 else if ((stocknumber[i]>=3001) && (stocknumber[i]<=5000))
 
  discount[i]=float(10)/100;
 
 else if ((stocknumber[i]>=5001) && (stocknumber[i]<=8000))
 
  discount[i]=float(15)/100;
 
 else if ((stocknumber[i]>=8001) && (stocknumber[i]<=9999))
 
  discount[i]=float(20)/100;
 }
 
 for (i=0;i<5;i++)
 {
 pricetopay[i]=calpricetopay(quantity,price);
 discountprice[i]=caldiscountprice (discount,pricetopay);
 priceafterdiscount[i]=calpriceafterdiscount(pricetopay,discountprice);
 }
    for (i=0;i<5;i++)
 {
 cout<<endl;
 cout<<endl;
 cout<<"Invoice"<<endl;
 cout<<"============"<<endl;
 cout<<"Stock no:"<<stocknumber[i]<<endl;
 cout<<"Quantity:"<<quantity[i]<<endl;
 cout<<"Price per unit:"<<price[i]<<endl;
 cout<<"Discount given:"<<discountprice[i]<<endl;
 cout<<"Discounted Price:"<<priceafterdiscount[i]<<endl;
 }
 
 

  return 0;
}
float calpricetopay (int quantity[], float price[])
{
 int i;
    float pricetopay[5];
 for (i=0;i<5;i++)
 {
  
 pricetopay[i]=float(quantity[i])*price[i];
 }
 return pricetopay[5];
 
 
}
float caldiscountprice (float discount[], float pricetopay[])
{
 int i;
 float discountprice[5];
 for (i=0;i<5;i++)
 {
 discountprice[i]=discount[i]*pricetopay[i];
 }
 return discountprice[5];
 
}
float calpriceafterdiscount(float pricetopay[], float discountprice[])
{
 int i;
 float priceafterdiscount[5];
 for (i=0;i<5;i++)
 {
 priceafterdiscount[i]=pricetopay[i]-discountprice[i];
 }
 return priceafterdiscount[5];
 
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.