When I execute this program in debug mode, the console screen may appear and dis
ID: 3913729 • Letter: W
Question
When I execute this program in debug mode, the console screen may appear and disappear
before I have an opportunity to view the output. How do I keep this from happening?
C++ code:
// ---------------------------------------------------------------
// Programming Assignment: LAB1A
// Developer: ______________________
// Date Written: ______________________
// Purpose: Ticket Calculation Program
// ---------------------------------------------------------------
#include <iostream>
using namespace std;
void main()
{
cout << "John Doe ticket program ";
int childTkts, adultTkts, totalTkts;
cout << "Please enter the number of child tickets:";
cin >> childTkts;
cout << "Please enter the number of adult tickets:";
cin >> adultTkts;
totalTkts = childTkts + adultTkts;
cout << "The total tickets are: "<<totalTkts << endl;
}
Explanation / Answer
You can run the application in debug mode and in release mode. Normally Ctrl + F5 will run the application without debugger. And F5just runs the application.
If you do Ctrl+F5 ("Start without Debugging"), the console remains open at the end and asks you to Press any key to continue . . . here you can see the output.
If you are just using F5 then you are in a debug mode. At the end you add, getchar() function before retuen 0;so the console will wait until you press any key...
Hope this will help
Please comment for any further clarifications
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.