473,387 Members | 1,391 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Introductory program broke

23
Well I'm trying to learn C++ (know a little Python) and I wrote what was supposed to be a quick and easy four function calculator. Well, after finally getting the compiler to work without any errors or warnings, the program wouldn't open up or do anything. It was running, though, and I had to close it via the processes tab, because I couldn't see it.

Anyone got any ideas on this one?

EDIT:
Oh, and I'm using wxDev-C++ if that makes any difference.

EDITEDIT:
Ah, reading another thread led me to a site that mentioned the answer. I chose 'blank application' when I should have chosen 'console application'.

This leads me to another problem, though, and it will probably help me along the road to find the answer now. I went into the properties dialog for the project and changed the compiler to 'console application', where it was (if I'm not mistaken, I could be doing it wrong) on GUI application. That didn't do anything, though. I had to start a new project and copy/paste the code.

EDITEDITEDIT(heh):
Also, this behavior seems to be inconsistent. I've chose 'blank application' with another example with no problem.

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. float FourFunc(float Num1, float Num2, int Choice)
  6. {
  7.     float Answer = 0;
  8.     switch(Choice)
  9.     {
  10.         case 1:
  11.             Answer = Num1 + Num2;
  12.             break;
  13.         case 2:
  14.             Answer = Num1 - Num2;
  15.             break;
  16.         case 3:
  17.             Answer = Num1 * Num2;
  18.             break;
  19.         case 4:
  20.             Answer = Num1 / Num2;
  21.             break;
  22.     }
  23.     return Answer;
  24. }
  25.  
  26. int main()
  27. {
  28.     cout<<"-----------------FourFunc Calc-----------------------\n";
  29.     int Choice;
  30.     float Num1, Num2;
  31.     bool On = 1;
  32.     while (On == 1)
  33.     {
  34.         cout<<"Please choose one of the following options: \n";
  35.         cout<<" 1:Addition\n 2:Subtraction\n 3:Multiplication\n 4:Division\n 5:Quit\n";
  36.         cin>>Choice;
  37.         if (Choice != 5)
  38.         {
  39.             if ((Choice > 0) && (Choice < 6))
  40.             {
  41.                 cout<<"Enter number: ";
  42.                 cin>>Num1;
  43.                 cout<<"\nEnter number: ";
  44.                 cin>>Num2;
  45.                 cout<<"\nThe answer is: "<< FourFunc(Num1, Num2, Choice);
  46.             }
  47.             else
  48.             {
  49.                 cout<<"\nThere seems to have been an Input Error. You might try again.";
  50.             }
  51.         }
  52.         else
  53.         {
  54.             On = 0;
  55.         }
  56.     }
  57.     return 0;
  58. }
  59.  
Feb 24 '08 #1
3 1180
sicarie
4,677 Expert Mod 4TB
I'm using GCC, and that compiles and runs well for me (though you may want to add a newline after the answer is output, or immediately before the P in the menu, as it currently all sits on one line).
Feb 24 '08 #2
Bellum
23
Yeah, sorry about that. Seems I was having trouble with my compiler.
Feb 24 '08 #3
sicarie
4,677 Expert Mod 4TB
Oh, no problem, hope you get your compiler working again!
Feb 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: A.M. Kuchling | last post by:
A new set of introductory pages for python.org is being developed. The current draft of a revised version is at http://www.python.org/topics/learn/ . If you're learning or have recently learned...
34
by: John Harrison | last post by:
An odd confession; an odd request; but here's the tale.... My company has a few PC systems which we have used for about 7 years and not updated - we've "made do", and besides, "if it ain't...
6
by: tigrfire | last post by:
I've been working on a program to try and play a game of Craps, based on a version I found elsewhere - I didn't code the original, but I added a few things such as a balance and wager system. I'm...
7
by: Tau | last post by:
Because vc8 uses MFC80.dll, and many PCs don't have these libraries... So I wonder if I can use vs2005's IDE to write a vc6 program? I mean just using mfc42.dll, etc...to make it runnable on other...
14
by: electrician | last post by:
While running a program that exceeds the array limits it issues an alert. I want to then stop the program after filling in the output boxes with blanks. How do you stop the program? I have...
21
by: Alok | last post by:
While posting a comment on http://www.reddit.com I got an error page with the following curious statement on it. "reddit broke (sorry)" "looks like we shouldn't have stopped using lisp..." ...
9
by: kaushalgoa | last post by:
int sum(int a, int b) { int c = a + b; } int main() { int p = 5, q = 10; printf("%d, %d, %d\n", p,q,sum(p,q));
1
by: mark4asp | last post by:
I moved a page to another web-site and now it's broke! I had 5 pages in their own web-site. These pages have now been moved to another web-site. Everything is fine except that one of the pages,...
1
by: Angel Tsankov | last post by:
Hello! Can someone recommend articles on migrating native C++ DLLs to managed C++ ones or an introductory book (or article) on .NET?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.