simple program one error ???

This is a discussion on simple program one error ??? within the C++ Programming forums, part of the General Programming Boards category; [code] #include <iostream> using namespace std; int main() /*function main*/ { float bal = 0; int months = 0; float ...

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    29

    simple program one error ???

    [code]


    #include <iostream>

    using namespace std;

    int main() /*function main*/
    {

    float bal = 0;
    int months = 0;
    float deposit = 0;
    int month = 0;
    float dep = 0;

    cout <<"Please enter the your balance $: (-1 to stop) ";
    cin >> bal;

    cout <<"How many months has the account been opened?: (-1 to stop) ";
    cin >> months;

    while (months >=1)////start loop
    {
    cout <<"Please enter any deposits $: (-1 to stop) ";
    cin >> dep;
    if (bal == -1)
    break; //get out of the loop
    else;
    month--;
    bal += dep;
    cout <<"Your balance is" << bal <<; ?sytax error here?



    return 0;




    [code]
    }

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    29
    oops

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main() /*function main*/
    {
    
    float bal = 0;
    int months = 0;
    float deposit = 0;
    int month = 0;
    float dep = 0;
    
    	cout <<"Please enter the your balance   $: (-1 to stop) ";
    	cin >> bal;
    
    	cout <<"How many months has the account been opened?: (-1 to stop) ";
    	cin >> months;
    
    	while (months >=1)////start loop
    		
    		cout <<"Please enter any deposits   $: (-1 to stop) ";
    		cin >> dep;
    		if (bal == -1)
    		break;							//get out of the loop
    		else;
    		month--;
    		bal += dep;
    		cout <<"Your balance is" << bal <<;	
    	
    				
    	
    	return 0;
    }

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    29
    any idea why i would get a syntax error on the last cout statement

    thanks for any help .....

  4. #4
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Code:
    cout <<"Your balance is" << bal <<;
    Remove the last '<<'.

    Oh and you may also want to notice the edit button
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  5. #5
    Registered User
    Join Date
    Sep 2004
    Posts
    29
    edit button?

  6. #6
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Yeah, look at the bottom right corner in your posts, just left of the quote button. That way you can just fix the code tags in your original post rather than posting a reply
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  7. #7
    Registered User
    Join Date
    Sep 2004
    Posts
    29
    oh cool this thing still runs into an end of file error ?????

    any ideas

  8. #8
    Registered User
    Join Date
    Sep 2004
    Posts
    29
    found it duh

  9. #9
    Never Exist Hermitsky's Avatar
    Join Date
    Jul 2004
    Posts
    149
    you lost "{}" while you are using "while"



    Code:
    #include <iostream>
    
    using namespace std;
    
    int main() /*function main*/
    {
    
    float bal = 0;
    int months = 0;
    float deposit = 0;
    int month = 0;
    float dep = 0;
    
    	cout <<"Please enter the your balance   $: (-1 to stop) ";
    	cin >> bal;
    
    	cout <<"How many months has the account been opened?: (-1 to stop) ";
    	cin >> months;
    
    	while (months >=1)////start loop
    	{	
    		cout <<"Please enter any deposits   $: (-1 to stop) ";
    		cin >> dep;
    		if (bal == -1)
    		break;							//get out of the loop
    		else;
    		month--;
    		bal += dep;
    		cout <<"Your balance is" << bal;	
    	}			
    	
    	return 0;
    }

    blow me ... ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  3. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 11:17 AM
  4. using c++ in c code
    By hannibar in forum C Programming
    Replies: 17
    Last Post: 10-28-2005, 10:09 PM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-30-2005, 12:21 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21