pls help me on solving my project. this program isrunning but when i press enter it will be sent back to the compiler. pls help me thanks in advance

#include<stdio.h>
#include<conio.h>
#include<string.h>
string();
int x,i,a,b,y;
int stocks[5]={4,5,3,6,2};
int code[5]={100,101,102,103,104};
float cost[5]={5000.00,4000.00600.00,3500.00,7000.00};
char des[5]={'t',d',v',v',c'};
float PA ,dis,net_pay,downpayment,monthly;
int main()
{
clrscr();
printf("\t\t\t CS213 Sales system\n");
printf("\t\t\t   24\n");
printf("\t\t\t Lapu-Lapu City\n");
printf("1.Product search\n");
printf("2.Delete a Product\n");
printf("3.Sell Product\n\n");
printf(" Select you Option\n\n");
scanf(:%d",&x);
switch(x)
{
case 1:
{
printf("Enter Product code:");
scanf("%i",b);
for(i=0; i<3; i++)
if (i==b)
{
printf(" Product code description unit cost stocks on hand\n");
printf("%d &c %6.2f %i\n",code[i],des[i],cost[i],stocks[i]);
}
else
{
}
break;
}
case 2:
printf(" Do you want to add product?\n");
{
printf("Enter product code:");
scanf("%d",&code[i]);
printf("description:");
scanf(%s",&des[i]);
printf(" Unit cost:");
scanf("%f",&cost[i]);
printf("quantity:");
scanf("%d",&stock[i]);
break;
case 4:
{
printf("no. of items:");
scanf("%i",&y);
for (i=0 ; i<y ; i++)
{
printf("Enter product code:");
scanf("%i",&code[i]);
if(code[i]==code[i])
{
printf(" Product code description unit cost\n");
{
pritf("%d %c %6.2f\n",code[i],des[i],cost[i]);
}
else
{
printf("Out of stock\n");
}
PA=PA+cost[i];
}
printf('\n Total purchased amount: %6.2f\n",PA);
printf("\n\n mode of payment:\n");
printf(" 1.CA   \n");
printf(" 2.3ma \n");
printf(" 3.3mb \n");
printf("\n mode:");
scanf(%i",&x);
switch(x)
case 1:
if (PA>=1500)
{
dis+PA.10;
net_pay=PA-dis;
printf("\n Total purchased amount: %6.2f",dis);
printf("\n net pay: %6.2f",net_pay);
}
else
{
net_pay=PA;
printf("\n Total purchased amount: %6.2f",PA);
printf("\n Discount: %6.2f",dis);
printf(\n net pay:%6.2f",net_pay);
}
break;
case 2:
printf("\n Down payment:");
scanf("%f",&down);
downpayment=PA*.30;
if (PA>=1500&& down>=downpayment)
{
printf("\n Total purchased amount:%6.2f\n",PA);
dis=PA*.05;
net_pay=PA-dis;
monthly=(net_pay-down)/3;
printf("\n 3 Months to pay:");
printf("\n Discount: %6.2f",dis);
printf("\n net_ pay:%6.2f",net_pay);
printf("\n Monthly: %6.2f",monthly);
}
else
{
net_pay=PA;
Monthly+PA/3;
printf("\n Total purchased amount:%6.2f,PA);
printf("\n 3Months to pay");
printf(" Discount:%6.2f"dis);
printf("\n Net pay:%6.2f",net_pay);
printf("\n Monthly:%6.2f",monthly);
}
break;
case 3:
{
Net_pay=PA
Monthly=PA/3
printf("\n Total purchased items: %6.2f",PA);
printf("\n No incentives");
printf("\n 3 Months to pay:");
printf("\n Discount:%6.2f",dis);
printf("\n Net pay:%6.2f",net_pay);
printf('\n Monthly"%6.2f",monthly);
}
break;
default:
{
printf("Invalid input");
}
getch();
return 0;

Recommended Answers

All 4 Replies

Your code is riddled with syntax errors. So many, in fact, that it's not even worth my time to point them out for you. I recommend you scrap your code and start over, but this time, pay close attention to what you're doing (programming requires an eye for detail) and compile often. That way you can weed out syntax errors when there are one or two rather than twenty or thirty.

line 21 is a syntax error that your compiler should have complained about. Maybe its just a posting error ?

After using scanf() to get an integer, scanf() leaves the '\n' in the keyboard buffer so the next time you call scanf it will appear as if it is not doing anything. The way to correct that is to remove the '\n' after calling scanf for integer input by to call getchar().

The fact that your syntax colouring has gone haywire should be a big hint to what's amiss.

And would it kill you to use some indentation (or indeed any white space).

And would it kill you to use some indentation (or indeed any white space).

Exactly. Study this.

commented: Nice link +11
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.