Hello All,

I'm very new to C++ and programming in general and am having probelms with an assignment i have been set. I've been using ?Blood dev C++? ( i dont know if this is any good?) I have basically finished the program and am getting one syntax error that i cannot figure out. In desperation i post here in order to pick your brains :o

Essentially the problems is on line 54:

int twentynote = int rtotal / 2000; // work out if various amounts fit.

the error as it it shows on screen:
in function 'int main(int, char**)':
syntax error before '/' token.

I haven't come toask for any help with the coding (no matter how bad it is :D ) just some help with this error would be great. the code is below.


#include <iostream>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[])

{
float total;
float flint;
int rtotal;

int twentynote;
int tennote;
int fivenote;
int twocoin;
int onecoin;
int fiftypcoin;
int twentypcoin;
int tenpcoin;
int fivepcoin;
int twopcoin;
int onepcoin;


{
cout<<"\nPlease enter amount required in the format Pounds and Pence '££.pp' ";

cin>>total;

flint = total * 100;
rtotal = (int)flint;
}

do{

int twentynote = int rtotal / 2000; // work out if various amounts fit.

if twentynote > 0
{
int rtotal = int rtotal % 2000;
}
}


{
int tennote = int rtotal / 1000;
if tennote > 0
{
int rtotal = int rtotal % 1000;

Remove the int from in front of rtotal. Type names are (for the most part) only used in declarations and type casts. Because your use is neither of those, it's a syntax error. Of course, the code you've posted has other syntax errors as well.

Thx for the reply Narue,

I've done as you have suggested and the compiler error has moved to the next line:

syntax error in '>' token.

is this related to the other syntax errors you have spotted? any chance of spelling them out for a noobie? : :lol:

Let's solve this one error at a time, use

if (twentynote > 0)

hint, conditional statements should be in (). That goes for all your if and while.

... and oh yes, Dev-C++ is very good for student use!

Hi Chaps,

I think I have sussed it. It was the int entrys as narue said and also my if staetemnt wasnt in brackets :o ahh well you live and learn :cheesy:

thX

Hey babablacksheep

I don't know if this will be of any help to you, but try this:

int twentynote, tennote, fivenote....;

This way you can 'int' everything in one line. Obviously you should only do this if all of the variables you are 'int'ing are the same (eg string)

(",)

>This way you can 'int' everything in one line.
You can "declare" everything with the same type on one line. The wording you used is potentially confusing. Also, while vertical space is abundant, horizontal space is more valuable. Learn to use it wisely. For example, it's widely accepted that single line declarations should consist of closely related variables, if they're used at all.

In this case, an array would be better than any measure of formatting of multiple variables.

This question has already been answered. Start a new discussion instead.