Hi,
I am trying to make a simple program of two array, one array will hold the string of names of type of salsa bottles, and other one will hold number of bottles sold:
I wanted to do this problem with function, so my code works fine for the part until taking array input from user, and finding max and min, however when I try to print the name[] array and sale[] array, I get an stackdump error "1 [main] chips 560 open_stackdumpfile: Dumping stack trace to chips.exe.stackdump".
I will really appreciate if someone can help me with this, my code is below:
/*
* chips.cpp
*
* Created on: Jan 19, 2014
* Author: BK
*/
#include<iostream>
#include<iomanip>
#include<string>
#include<cstdlib>
for(i=1; i<=4; i++)
{
cout<<"enter sale for type "<<i<<" : ";
cin>>sale[i];
if(sale[i]<0)
{
while(sale[i]<0){
cout<<"enter only positive number : ";
cin>>sale[i];
cout<<"\n";
}
}
cout<<"\n";
if(sale[i]>max)
max=sale[i];
if(sale[i]<min)
min=sale[i];
}
cout<<"max sale is : "<<max<<"\n";
cout<<"min sale is : "<<min<<"\n";
for(int k=0; k<=4; k++)
{
cout<<"the salsa named : "<<name[k]<<" sold these many jars : "<<sale[k]<<"\n";
}
figured it out.. thanks again..
corrected code:
/*
* chips.cpp
*
* Created on: Jan 19, 2014
* Author: BK
*/
#include<iostream>
#include<iomanip>
#include<string>
#include<cstdlib>
for(i=0; i<5; i++)
{
cout<<"enter sale for type "<<i+1<<" : ";
cin>>sale[i];
if(sale[i]<0)
{
while(sale[i]<0){
cout<<"enter only positive number : ";
cin>>sale[i];
cout<<"\n";
}
}
cout<<"\n";
if(sale[i]>max)
max=sale[i];
if(sale[i]<min)
min=sale[i];
}
cout<<"max sale is : "<<max<<"\n";
cout<<"min sale is : "<<min<<"\n";
for(int k=0; k<5; k++)
{
cout<<"the salsa named : "<<name[k]<<" sold these many jars : "<<sale[k]<<"\n";
}