| | |
Check my code, There is 1 error, cant find it
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Oct 2007
Posts: 4
Reputation:
Solved Threads: 0
I tried to write a basic calculator program, Visual basic finds 1 error. I cant find it.
Please help. I am kind off new to programming.
Please help. I am kind off new to programming.
c++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main(void) { system("TITLE calculator"); system("COLOR 9"); char cChar; double dfirstnumber; double dsecondnumber; char cDoagain; do { system("CLS"); cout << "please enter the first number that you would like to use" << endl; cin >> dfirstnumber; cout << "please enter the operation that you would like to complete" << " (+,-,* or /) " << endl; cin >> cChar; cout << "please enter the second number you would like to use" << endl; cin >> dsecondnumber; switch (cChar) { case '+': cout << " the answer is: " << dfirstnumber << " + " << dsecondnumber << " = " << (dfirstnumber + dsecondnumber) << endl; break; case '-': cout << "the answer is: " << dfirstnumber << " - " << dsecondnumber << " = " << (dfirstnumber - dsecondnumber) << endl; break; case '*': cout << "the answer is: " << dfirstnumber << " * " << dsecondnumber << " = " << (dfirstnumber * dsecondnumber) << endl; break; case 'X': cout << "the answer is: " << dfirstnumber << " X " << dsecondnumber << " = " << (dfirstnumber * dsecondnumber) << endl; break; case 'x': cout << "the answer is: " << dfirstnumber << " x " << dsecondnumber << " = " << (dfirstnumber * dsecondnumber) << endl; break; case '/': if (dsecondnumber == 0) { cout << " that is invalid " << endl; }else{ cout << "the answer is: " << dfirstnumber << "/" << dsecondnumber << "=" << (dfirstnumber / dsecondnumber) << endl; } break; default cout << "that is an invalid operation" << endl; break; } cout << "would you like to start again? (y or n)" << endl; cin >> cDoagain; }while (cDoagain == 'y' || cDoagain == 'Y'); system("PAUSE"); return 0; }
Last edited by stymiee; Oct 23rd, 2007 at 9:48 pm. Reason: added code tags
I am very surprised that Visual Basic found only one error considering this code isn't written in Visual Basic ... it's written in C++.
Dani the Computer Science Gal 
Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds

Follow my Twitter feed! twitter.com/DaniWeb
And if you're interested in Internet marketing there is twitter.com/DaniWebAds
You need to describe the error. No one is going to spend an hour trying to find the error, then pour over your code to fix it. You need to describe the error and the circumstances with which it happens.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
![]() |
Similar Threads
- CALENDAR in TASM!!(pls check my code!!:) (Assembly)
- could you check my code ? (C)
- Hey check out my prog. It has an error can u find it? (Java)
- Again please someone check my code (C++)
- Number puzzle help (C)
- How do i fix this? (C++)
- DNS error cannot find server (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: help plz
- Next Thread: Quick Question! Post/pre Inc!
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






