how can i fix this???(sorting)

#include<iostream.h>
#include<ctype.h>

double vat(double x);

struct compute
{
char name[80];
};

compute sug[80];
int limit,cntr;
double price[80][80];

const double num=limit;

void main()
{

cout<<"\nhow many item(s):";
cin>>limit;


for(cntr=0;cntr<limit;cntr++)
{
cout<<"\nitem name:";
cin>>sug[cntr].name;
cout<<"\nitem price:";
cin>>price[cntr][0];

price[cntr][1]=vat(price[cntr][0]);

}

cout<<"\nROMMAR's STORE";

cout<<"\nname\tprice\tw/vat";


{
cout<<"\n"<<sug[cntr].name<<"\t"
<<price[cntr][0]<<"\t"
<<price[cntr][1]<<endl;

}

double data[num]={price[cntr][1]};
int i,j,k;
double temp;
temp=0;

cout<<"\nthe data in the list:"<<endl;
for(i=0;i<num;i++)
cout<<" "<<data[i];

for(j=0;j<num;j++)
{
for(k=1;k<num;k++)
{
if(data[k]<data[k-1])
{
temp=data[k];
data[k]=data[k-1];
data[k-1]=temp;
}
}
}
cout<<endl;

cout<<"\nthe sorted list in ascending order is:"<<endl;

for(i=0;i<num;i++)
cout<<" "<<data[i];

cout<<endl;




}
double vat(double x)
{
double z;
z=x+(x*0.12);
return(z);
}



Last edited on
For started you could use code tags. And then you should also post what errors you're having.
But from what I can see:
main should not be a void type
You cannot declare array sizes with doubles (Num)...(I think)
You're not using namespace std so all couts, cins and endls should be declared as std::cout etc.
Anything else I may have missed?
warnis

double data[num]={price[cntr][1]};-----------this part is the error..

if i can't use array then what should i use?
our prof.ask us to make a program..where in the user will input the item name and the item price they bought.then the program will
SORT
the items to ascending order by means of cost of the item..
Last edited on
You could copy the values of price[cntr] into data.
example:
1
2
3
4
5
6
7
8
9
10
11
int main()
{
    int arr[3][3] = {{1,2,3},{4,5,6},{7,8,9}};
    int data[3];
    for(int i=0; i<3; i++)
    {
        data[i] = arr[0][i];
        std::cout << data[i] << std::endl;
    }
    return 0;
}
1
2
3

Don't forget to change num into an int either.
That code is just to hard to read as is, I'm not commenting until it's edited with code tags.
Topic archived. No new replies allowed.