Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
[Error] expected identifier or '(' before '{'

What I have tried:

C++
#include <stdio.h>
int main ()
{
	printf("Welcome to Health is Wealth Co Customer's Data"); }
	
 char Q;
 {
 
    printf("Quit program");
    
    if (enter Q)

       printf("Thank you for using the system. Have a nice day\n");	
       
 
    char E()


	printf("Enter order\n");

	if (enter E)
	   
	
   	int quantity;
   	float price, SubtotalAmount;
   	printf("Enter quantity and price:");
	scanf("%d%f", &quantity * price);
	
	SubtotalAmount = quantity * price;
	printf("The subtotal amount is:\n% * RM %.2f\n", quantity, price, SubtotalAmount);
	return 0;
	
 }
Posted
Updated 19-May-21 20:09pm
v3

You REALLY need to go through your code and clean up the curly braces and parenthesis. They are screwed up and what is causing your problems. They MUST match up correctly.
 
Share this answer
 
v2
As Dave wrote you must clean up your code at first. In this effort most IDE like Visual Studio have some helping functions and shortcuts.

Writing clean code as primary task helps you to avoid such mess and concentrate on the features.
 
Share this answer
 
As stated, sort out the braces and indentation: most IDEs will help you there, once you get the braces working.
But ... that code shows every sign of being thrown together without any thought or design effort being put into it, and that always a mistake.
These aren't valid C++:
if (enter Q)
Just rubbish!
C++
char E()
No semicolon
if (enter E)
More rubbish.Even if it was something sensible, the only code which would be executed if it evaluated to true is a single variable declaration - so it would immediately go out of scope anyway!
scanf("%d%f", &quantity * price);
Two fields, needs two output locations. What on earth does an address multiplied by any number mean? Think about address as mobile phone numbers: if I multiply your phone number by 3 and dial the result, who do I call?
printf("The subtotal amount is:\n% * RM %.2f\n", quantity, price, SubtotalAmount);
Two outputs specified, three provided.

That code says one thing to me: "I can't be bothered to learn and think about this subject". I'd strongly suggest you start with your course notes from the beginning again, and then start from scratch with this assignment - what you have there isn't worth saving!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900