| | |
New to C++ need some help
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2005
Posts: 23
Reputation:
Solved Threads: 0
The following code works. However i want it so when the user reaches 500 dollars the last cout statement will run. But for some reason i can't get it to work properly. It skips the last cout statment and enters -numbers.
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main () { int money = 500; int moneyspent; do { cout<<"Please enter how much money you would like to spend"<<endl; cin >> moneyspent; if(moneyspent < 500) money = money - moneyspent; cout<<"You have "<<money<<" dollars left to spend"<<endl; } while(moneyspent != 500); cout <<"You are out of cash jarboni"<<endl; return 0; }
Last edited by Dave Sinkula; Oct 29th, 2005 at 6:33 pm. Reason: Added [code][/code] tags.
![]() |
Other Threads in the C++ Forum
- Previous Thread: queue implementation error
- Next Thread: Cbuilder Fullscreen form how to ???
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






