423,851 Members | 2,762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,851 IT Pros & Developers. It's quick & easy.

Facing an error like... EXPECTATION 13:generalprotection fault at 08C7:210E error cod

P: 1
While Compiling this below mentioned code, I faced through an error of General Protection Fault.I want to know where is the error in my code.

#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<process.h>
typedef float amount;
typedef int choice;
int billing(float,int);
class cust{
char name[30],address[200],gen,eid[30];
double mobno;
public:
void getdata()
{
fstream cust;
cust.open("cust",ios::in);
cout<<"\n Enter your Name: ";
cin>>name;
cout<<"\n Enter your Gender(M/F): ";
cin>>gen;
cout<<"\n Address: ";
cin>>address;
cout<<"\n Mobile number:";
cin>>mobno;
cout<<"\n email id: ";
cin>>eid;
cust<<"\n Registered Mobile no.: "<<mobno;
cust<<"\n Name:"<<name<<"\n Address"<<address;
cust<<"\n Email id:"<<eid;
}
void display()
{cout<<"\n Your Registered Mobile no.: "<<mobno;
cout<<"\n\n Name:"<<name<<"\n Address"<<address;
cout<<"\n Email id:"<<eid;
}
double getmob()
{return mobno;}
}c;

void main()
{ clrscr();
amount price=0,cost=0,tot_price=0,fin_price=0;
choice ch,ch1,ch2,ch3;
int qty;
cout<<"\n Welcome to Rel. Dig.";
cout<<"\n What are you here for: ";
cout<<"\n 1.Purchase \n 2.After Sale Activities. ";
cout<<"\n\n Enter your choice(1/2): ";
cin>>ch1;
switch(ch1)
{
case 1:{int ch2;
lb:
cout<<"\n\n Menu:";
cout<<"\n 1.Televisions";
cout<<"\n 2.Mobiles";
cout<<"\n 3.Laptops";
cout<<"\n\n Enter your choice(1/2/3):";
cin>>ch2;
switch(ch2)
{
case 1:{int ch3;
cout<<"\n Menu(Models)";
cout<<"\n **********Models********** ********Price********";
cout<<"\n 1.Sony Bravia 4K UHD(55 inch) | Rs.1,20,000 ";
cout<<"\n 2.Panasonic UHD(55 inch) | Rs.80000 ";
cout<<"\n 3.Micromax HD Ready(42 inch) | Rs.50000 ";
cout<<"\n\n Choice(1/2/3):";
cin>>ch3;
switch(ch3)
{
case 1:{price=120000;
cout<<"\n Quantity: "; cin>>qty;
cost=price*qty;
cout<<"\n Discount: 20%";
tot_cost=cost-(0.2*cost);
cout<<"\n GST @ 10%.";
fin_cost=tot_cost+(0.1*tot_cost);
cust.getdata();
}break;
case 2:{price=80000;
cout<<"\n Quantity: "; cin>>qty;
cost=price*qty;
cout<<"\n Discount: 20%";
tot_cost=cost-(0.2*cost);
cout<<"\n GST @ 10%.";
fin_cost=tot_cost+(0.1*tot_cost);
cust.getdata();
}break;
case 3:{price=50000;
cout<<"\n Quantity: "; cin>>qty;
cost=price*qty;
cout<<"\n Discount: 20%";
tot_cost=cost-(0.2*cost);
cout<<"\n GST @ 10%.";
fin_cost=tot_cost+(0.1*tot_cost);
cust.getdata();
}break;
default:{cout<<"\n Model Unavailable!! ABORTING!!!";
exit(0);}
break;
}
break;
case 2:{int ch3;
cout<<"\n Menu(Models)";
cout<<"\n ******Models****** ******Price******";
cout<<"\n 1.Apple iPhone XS | Rs.85000 ";
cout<<"\n 2.Samsung Galaxy Note 9 | Rs.65000 ";
cout<<"\n 3.OnePlus 6T | Rs.35000 ";
cout<<"\n 4.VIVO V11 Pro | Rs.30000 ";
cout<<"\n Choice(1/2/3/4):";
cin>>ch3;
switch(ch3)
{
case 1:{price=85000;
cout<<"\n Quantity: "; cin>>qty;
cost=price*qty;
cout<<"\n Discount: 10%";
tot_cost=cost-(0.1*cost);
cout<<"\n GST @ 5%.";
fin_cost=tot_cost+(0.05*tot_cost);
cust.getdata();
}break;
case 2:{price=65000;
cout<<"\n Quantity: "; cin>>qty;
cost=price*qty;
cout<<"\n Discount: 10%";
tot_cost=cost-(0.1*cost);
cout<<"\n GST @ 5%.";
fin_cost=tot_cost+(0.05*tot_cost);
cust.getdata();
}break;
case 3:{price=35000;
cout<<"\n Quantity: "; cin>>qty;
cost=price*qty;
cout<<"\n Discount: 10%";
tot_cost=cost-(0.1*cost);
cout<<"\n GST @ 5%.";
fin_cost=tot_cost+(0.05*tot_cost);
cust.getdata();
}break;
case 4:{price=30000;
cout<<"\n Quantity: "; cin>>qty;
cost=price*qty;
cout<<"\n Discount: 10%";
tot_cost=cost-(0.1*cost);
cout<<"\n GST @ 5%.";
fin_cost=tot_cost+(0.05*tot_cost);
cust.getdata();
}break;
default:{cout<<"\n Model unavailable!!.";
exit(0);}
break;
}
case 3:{int ch3;
cout<<"\n Menu(Models)";
cout<<"\n ******Models****** ******Price****** ";
cout<<"\n 1.Dell G7(i9) | Rs.125000 ";
cout<<"\n 2.Apple Macbook Air(i7) | Rs.95000 ";
cout<<"\n 3.HP Pavilion(i5) | Rs.70000 ";
cout<<"\n Choice(1/2/3/4):";
cin>>ch3;
switch(ch3)
{
case 1:{price=85000;
cout<<"\n Quantity: "; cin>>qty;
cost=price*qty;
cout<<"\n Discount: 10%";
tot_cost=cost-(0.1*cost);
cout<<"\n GST @ 5%.";
fin_cost=tot_cost+(0.05*tot_cost);
cust.getdata();
}break;
case 2:{price=65000;
cout<<"\n Quantity: "; cin>>qty;
cost=price*qty;
cout<<"\n Discount: 10%";
tot_cost=cost-(0.1*cost);
cout<<"\n GST @ 5%.";
fin_cost=tot_cost+(0.05*tot_cost);
cust.getdata();
}break;
case 3:{price=35000;
cout<<"\n Quantity: "; cin>>qty;
cost=price*qty;
cout<<"\n Discount: 10%";
tot_cost=cost-(0.1*cost);
cout<<"\n GST @ 5%.";
fin_cost=tot_cost+(0.05*tot_cost);
cust.getdata();
}break;
case 4:{price=30000;
cout<<"\n Quantity: "; cin>>qty;
cost=price*qty;
cout<<"\n Discount: 10%";
tot_cost=cost-(0.1*cost);
cout<<"\n GST @ 5%.";
fin_cost=tot_cost+(0.05*tot_cost);
cust.getdata();
}break;
default:{cout<<"\n Model unavailable!!.";
exit(0);}
break;
}break;

case 2: {
char found='n';
double mobl;
cout<<"\n\n Please enter your registered mobile number: ";
cin>>mobl;
fstream s("cust",ios::in);
while(!s.eof())
{ s.read((char*)&c,sizeof(c));
if(cust.getmob()=mobl)
{
c.display();
found='y';
break;
}
}
if(found='n')
cout<<"\n\n Mobile Number not found in file";
cout<<"\n\n Is your item still in Warranty Period?(y/n): ";
cin>>wch;
if(wch=='y'||wch=='Y')
{cout<<"\n\n As your product is still in your Warranty Period, \n we are able to Provide you these services: ";
lb1:
cout<<"\n 1.Servicing. (Free) ";
cout<<"\n 2.Replacement of every Breakage items @Rs.2500/- each.";
cout<<"\n 3.Exchange offer:";
cout<<"\n (We are ready to Provide you any of the Products with a cashback of Rs.15000/-.)" ;
cout<<"\n\n\n How can we help you?(1/2/3): ";
cin>>wch1;
switch(wch1);
{
case 1 :cout<<"\n\n Your product has been serviced";
break;
case 2 :{ randomize();
int brk=1+random(3);
cout<<"\n\n There were "<<brk<<" defective items";
cout<<"\n All are Replaced!!";
fin_cost=brk*2500;
cout<<"\n\n Total Cost: Rs."<<fin_cost;
}break;
case 3 : goto lb;
break;
default:{cout<<"\n Can't Help you out!! Sorry!!";
cout<<"\n\n Do you want to Continue?(y/n): ";
cin>>wch2;
if(wch2=='y'||wch2=='Y')
{ goto lb1;}
else
exit(0);
}break;
}
default: {cout<<"\n\n Choice Unavailable!!.......Aborting!";
exit(0);}break;
}
} //End of Main.

int billing(float cost, int ch1)
{ int ch;
long otp;
if(ch1==2) cost=cost-15000;
cout<<"\n\n *---------------------*---------------------*------------------*----";
cout<<"\n\t\t Your Total Bill: Rs."<<cost;
cout<<"\n\t\t Rounding off : Rs."<<(int)cost;
lb2:
cout<<"\n\n\t\t Payment Modes:":
cout<<"\n\t\t 1.Cash. ";
cout<<"\n\t\t 2.Net Banking(Recommended).";
cout<<"\n\t\t Your Payment Option(1/2): ";
cin>>ch;
switch(ch)
{
case 1:{ cout<<"\n\n\t\t Thankyou for Shopping at Reliance Digital. \n\t\t We Believe at making your lives fully advanced through latest Technologies.";
}break;
case 2:{ cout<<"\n\n\t\t Please enter your Mobile number(Registered with the Bank. :";
cout<<"\n\t\t An OTP has been sent to your Mobile.";
cout<<"\n\t\t Please enter the (4-Digit) OTP received.: ";
cin>>otp;
if(otp==0000)
{ cout<<"\n\n\t\t Transaction Complete!";
cout<<"\n\n\t\t Thankyou for Shopping at Reliance Digital. \n\t\t We Believe at making your lives fully advanced through latest Technologies.";
}
else
{cout<<"\n\n\t\t INCORRECT OTP!!! TRANSACTION FAILED. ABORTING! ";
exit(0);}
}break;
default: {cout<<"\n\n\t\t Payment Mode Unavailable!! \n\t\t Please Try Again.";
goto lb2;}break;
}
return 0;
}
3 Weeks Ago #1
Share this Question
Share on Google+
1 Reply


weaknessforcats
Expert Mod 5K+
P: 9,196
The code you posted won't compile at all. There are missing braces and other syntax errors. Please fix those errors and repost.
3 Weeks Ago #2

Post your reply

Sign in to post your reply or Sign up for a free account.