Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Syntax error: expected ';' before string constant!

string syntax syntax error

  • Please log in to reply
2 replies to this topic

#1 Steamsteam

Steamsteam

    CC Regular

  • Just Joined
  • PipPipPip
  • 27 posts

Posted 23 October 2010 - 05:02 PM

I get this at least twice when I first write a program. I always manage to fix it via fiddling but I would like to know why I keep getting it. It always is a ** to fix it too. Error is on line 27 (bolded). Thanks in advance!


#include <iostream>
using namespace std;
int main ()
{
    char loop;

    //loop to be repeated
    do
    {

        const double raise = 0.076;
        int months;
        double pre_salary, monthly_salary, half_salary, new_salary, single_month;
        cout.setf(ios::fixed);
        cout.setf(ios::showpoint);
        cout.precision (2);


        cout << "This program is designed to calculate your new annual salary \n"
             << "due to your raise. Insert your previous years salary and press enter: " << endl;
        cin >> pre_salary;
        cout << "Now enter the ammount of months you are getting the bonus for: " << endl;
        cin >> months;
        half_salary = pre_salary*raise*months;
        new_salary = half_salary+pre_salary;
        monthly_salary = new_salary/months;
       [b] cout << "Your new anual salary is: " << new_salary << "You earn " << half_salary "\n";[/b]
        cout << "dollers more this year. Your monthly increase for the " << months << " months is: \n";
        cout << monthly_salary << endl;
        cout << "If you would like to recalculate for a friend, press Y and enter:" << endl;
        cin >> loop;





    //end of loop
    }while (loop == 'Y' || loop == 'y');
    cout << "Goodbye!\n";
    return 0;
}

  • 0

#2 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 23 October 2010 - 05:14 PM

You for got another << in half_salary "\n"
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#3 Steamsteam

Steamsteam

    CC Regular

  • Just Joined
  • PipPipPip
  • 27 posts

Posted 23 October 2010 - 05:23 PM

OH before the "\n" thanks!
  • 0





Also tagged with one or more of these keywords: string, syntax, syntax error

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download