| | |
Windows gives an error after starting the .exe
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
Hi i am re-studying C.So I just wanted to do a simple calculator program.I am using dev-c++ anyways the code is below please help.
C++ Syntax (Toggle Plain Text)
#include <stdio.h> #include <conio.h> /*its a simple program that after getting the numbers from the user and inputs the operation*/ int main() { int i=0; int a=0; int b=0; int s=0; char o; while(i==i){ /*a simple for-ever loop*/ printf("Enter the first number"); scanf("%d",&a); printf("Enter the second number"); scanf("%d",&b); printf("What do you want to do with them?"); scanf("%c",o); switch(o) { case '+': s=a+b; printf("\n The sum is : %d" ,s); scanf(""); break; default : printf("\n invalid"); scanf(""); break; } } }
"By the data to date, there is only one animal in the Galaxy dangerous to man—man himself. So he must supply his own indispensable competition. He has no enemy to help him."
From Time Enough for Love by Robert A. Heinlein
From Time Enough for Love by Robert A. Heinlein
•
•
•
•
Originally Posted by johnroach1985
Hi i am re-studying C.So I just wanted to do a simple calculator program.I am using dev-c++ anyways the code is below please help.
You may want to take a look at a way to Read a Line of Text from the User and a way to Read a Number from the User.
scanf has a lot of issues that trip up beginners.
C++ Syntax (Toggle Plain Text)
scanf("%d",&b); printf("What do you want to do with them?"); scanf("%c",o);
scanf("%c",&o); "One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- Windows 2000 pro - svchost.exe using 100% cpu (Windows NT / 2000 / XP)
- ERROR C:\PROGRA~1\INTERN~1\iexplore.exe (Viruses, Spyware and other Nasties)
- Isass.exe unable to initialise (Troubleshooting Dead Machines)
- "Error message when starting Microsoft Word" (Viruses, Spyware and other Nasties)
- Help with windows explorer error (Web Browsers)
- Error message when starting Microsoft Word (Windows 95 / 98 / Me)
- Windows XP Boot Up Error 35. (Windows NT / 2000 / XP)
- windows protection error (Windows 95 / 98 / Me)
Other Threads in the C++ Forum
- Previous Thread: Guess! Guess! n Guess!!!
- Next Thread: cout << "Please Help" << endl;
| Thread Tools | Search this Thread |
api array arrays based binary bitmap c++ c/c++ calculator char char* class code coding compile console conversion count data database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






