This is my code...
i'm getting error that "Primary expression missing" in all places where i have ritn desc[i].code or desc[i].cost.
May be i'm using wrong syntax for strcutures;
#include<iostream>
#include<conio.h>
using namespace std;
struct desc
{
int code;
int cost;
};
void del(int x, int count)
{
int i;
for (i=0;i<count;i++)
{
if(desc[i].code==x)
{
desc[i].cost=0;
}
}
cout<<"Item deleted"<<endl;
}
void total( int count)
{
int i;
for(i=0;i<count;i++)
int sum=sum+desc[i].cost;
cout<<"Total item cost till now is: "<<sum;
}
void bill(int count)
{
int i;
cout<<"CODE\t"<<"Cost"<<endl;
for(i=0;i<count;i++)
{
cout<<desc[i].code<<"\t"<<desc[i].cost<<endl;
}
total();
}
int main()
{
cout<<"Welcome to departmental store";
int ch, count=0, desc[10];
while(1)
{
cout<<"1:To add an item";
cout<<endl<<"2:To delete an item";
cout<<endl<<"3:To view total amount";
cout<<endl<<"4:To view bill";
cout<<endl;
cin>>ch;
switch(ch)
{
case 1:
cout<<"Enter code number of item"<<endl;
cin>>desc[count].code;
cout<<"Enter cost of item"<<endl;
cin>>desc[count].cost;
count++;
break;
case 2:
cout<<"Enter code to delete"<<endl;
cin>>x;
del(x,count);
break;
case 3:
total(count);
break;
case 4:
viewbill(count);
break;
default:
exit 0;
}
getch();
}
}