C++ School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C++ Expert!

Join 300,480 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,762 people online right now. Registration is fast and FREE... Join Now!




expected primary expression

 

expected primary expression, this is my first program i am trying to create its probly all wrong bu

bluebadger

3 Jul, 2009 - 12:43 AM
Post #1

New D.I.C Head
*

Joined: 8 Jun, 2009
Posts: 3

CODE

#include <stdio.h>
#include <iostream>
using namespace std;
#define VAT = 17.5%;

int main ()
{
    float Value;
    float RevisedValue;
    
    cout << "enter value of item without tax";
    cin >> Value;
    RevisedValue = Value + 17.5%;
    cout << "original Value" << Value << endl;
    cout << "revised Value" << RevisedValue << endl;
    
    system ("pause");
  
    return 0;

/*this is the first program im creating from scratch on line 13 of this code i get the error expected primary expression i have not encounterd this error while creating previous demo programs could some one please explain the error to me possibly help fix my code its probably completely wrong but any help will be much appreciated*/


** Edit ** code.gif

This post has been edited by no2pencil: 22 Jul, 2009 - 10:43 PM

User is offlineProfile CardPM
+Quote Post


Richy321

RE: Expected Primary Expression

3 Jul, 2009 - 12:55 AM
Post #2

New D.I.C Head
*

Joined: 26 Jun, 2009
Posts: 17

add code tags.
add a question.

QUOTE
RevisedValue = Value + 17.5%;


You cant just add 17.5% to a value, your'll have to put the math in yourself. e.g.

CODE
RevisedValue = Value + ((Value /100)*17.5)


Isn't VAT 15% now? depends where your from i suppose.

This post has been edited by Richy321: 3 Jul, 2009 - 12:57 AM
User is offlineProfile CardPM
+Quote Post

bluebadger

RE: Expected Primary Expression

3 Jul, 2009 - 01:08 AM
Post #3

New D.I.C Head
*

Joined: 8 Jun, 2009
Posts: 3

[/quote]sorry for not putting in the tags im new to all of this i dont even own a pc so sorry for any mistakes or time wasting i may have caused, i altered the code as suggested including 15% tax thnx for the reminder of that but am still getting the same error could you at least tell me if im on the right track to creating a working program and any suggestions on how to get that error to jog on would be great im using dev c++ compiler if that makes any difference thanks for the quick reply richy you the man[/quote]

User is offlineProfile CardPM
+Quote Post

Richy321

RE: Expected Primary Expression

3 Jul, 2009 - 02:59 AM
Post #4

New D.I.C Head
*

Joined: 26 Jun, 2009
Posts: 17

No worries, keep at it, keep reading beginners tutorials / a good book.
Theres a couple of syntax errors,

CODE
#include <stdio.h>
#include <iostream>
using namespace std;
//removed define as its not needed.

int main ()
{  // main code block start
    float Value;
    float RevisedValue;

    cout << "enter value of item without tax ";
    cin >> Value;
    RevisedValue = Value + ((Value /100) * 15);   //Changed to calculate 15% vat -RJ
    cout << "original Value" << Value << endl;
    cout << "revised Value" << RevisedValue << endl;

    system ("pause");

return 0;
} // main code block end<---- always close any code block with a }


Prob did too much for ya there, next time make ya work a bit harder tongue.gif

This post has been edited by Richy321: 3 Jul, 2009 - 03:02 AM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic

Time is now: 11/8/09 03:52AM

Live C++ Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month