C++ Errors Using DEV-C++ !Help!!

Im having problems with the program code below. When I run the code in DEV-C++, it is suppose to execute a sequential selection, repetitive statement and a function call.

Unfortunately, When the command window prompt me to:

Welcome to programs of my cmis 102 course
Enter your choice of Selection or Repetition (ex:S/R):

When I enter S (s) or R and hit enter, the command window prompt disappears.

Could anyone assist me to execute a sequential selection, repetitive statement and a function call?

Program Assignment:

Write a simple working C++ program that utilizes a good design process and incorporates sequential, selection and repetitive programming statements as well as at least one function call.

My Code:

#include <iostream>
using std::cout;
using std::cin;

void bye(); // prototype of function

int main() // function main begins program execution
{
// sequential statements
char choice;

cout << "\n\n\tWelcome to programs of my cmis102 course \n\n\t";
cout <<"Enter your choice of Selection or Repetition (ex:S/R): ";
cin >> choice;

// selection statements
if ((choice == 's') || (choice =='S'))

cout <<"\n\n\tYou are in selection statement"
<<"\n\tand this is an example to the question";

else
{
// repetition statement
for (int i= 0; i < 3; i++)
cout <<"\n\t\tPosting the question #" << (i+1);
}

// a function call
bye();

return 0; // indicate program executed successfully
} // end of function, main

// prints the welcome message to the user
void bye()
{
cout <<"\n\n\tHope this code will work";
cout <<"\n\tHope my next code works.";
} // end function
[1947 byte] By [kottyn] at [2007-11-20 10:50:32]
# 1 Re: C++ Errors Using DEV-C++ !Help!!
Put in system("pause") before return 0. This will make the program prompt you before closing the console.
angelorohit at 2007-11-9 1:24:37 >
# 2 Re: C++ Errors Using DEV-C++ !Help!!
Im having problems with the program code below. When I run the code in DEV-C++, it is suppose to execute a sequential selection, repetitive statement and a function call. You created a command-line program, so why don't you run it from the command-line? You created an .EXE file, so open a Console window, go to that directory where you created the executable, and run the executable you created.

Regards,

Paul McKenzie
Paul McKenzie at 2007-11-9 1:25:37 >
# 3 Re: C++ Errors Using DEV-C++ !Help!!
Put in system("pause") before return 0. This will make the program prompt you before closing the console.Read treuss's post, and you'll see why this is bad advice, especially for a C++ program (and my comments also):

http://www.dev-archive.com/forum/showthread.php?t=433554

As stated, if it's a command-line program, putting in artificial means to pause the program will give you erroneous results for a C++ console program that wants to track object destruction.

Regards,

Paul McKenzie
Paul McKenzie at 2007-11-9 1:26:37 >
# 4 Re: C++ Errors Using DEV-C++ !Help!!
I understand the destructor issue but you should know that not everybody runs their programs from the command line. Many programmers use IDEs to make things simpler. As long as you know what is going on, I don't see the harm in using system("pause"). Also consider the OP's program which is simple and straight forward. Btw, even the sample Console application project that comes with DevCpp uses this line. I'm sure the developers of DevCpp have no qualms about issuing a simple DOS command.
angelorohit at 2007-11-9 1:27:40 >
# 5 Re: C++ Errors Using DEV-C++ !Help!!
I understand the destructor issue but you should know that not everybody runs their programs from the command line. Many programmers use IDEs to make things simpler. As long as you know what is going on, I don't see the harm in using system("pause"). Also consider the OP's program which is simple and straight forward. Btw, even the sample Console application project that comes with DevCpp uses this line. I'm sure the developers of DevCpp have no qualms about issuing a simple DOS command.
If you're running in an IDE, then just put a breakpoint at the last line of your code! There's still no need to add 'system("pause")' to your code.

Viggy
MrViggy at 2007-11-9 1:28:46 >
# 6 Re: C++ Errors Using DEV-C++ !Help!!
I understand the destructor issue but you should know that not everybody runs their programs from the command line. Many programmers use IDEs to make things simpler.Read my post from the other thread.

The IDE is there to create project management easier, and to write, compile, and debug programs. When you have to actually run the program to see the output and any other issues, the program *must* (not if, but must) be run in the environment it was created for at some point. Running from the IDE is an artificial way to run the program. Yes, it can give you a quick look at what's happening, but eventually, the program will be run from the environment it was meant to be run in. In this case, it is the command-line.

If a programmer can't just open a command window and run an executable, then I doubt whether they have the aptitude to be a programmer. Not only that, if a beginner programmer doesn't know where (or even what) the executable program is and how to run it correctly, what good did the "system(pause)" do them? The beginner programmer is running console programs from the IDE, and not know what is really going on.

As to Dev-CPP putting in the system("pause"), that doesn't help the person who is reading a generic C++ beginners book, and it has no "system(pause)" in the example programs. That seems to be the ongoing issue with so many posts here where the person is running and can't see the output.

As my other post stated, the Linux/Unix persons are probably laughing their heads off on this one ("Those Windows programmers are so inept, they don't even know how to run their own programs").

Regards,

Paul McKenzie
Paul McKenzie at 2007-11-9 1:29:49 >