Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6101005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:27:03+00:00 2026-05-23T13:27:03+00:00

I just started learning C++ and I wrote this sample program from the text

  • 0

I just started learning C++ and I wrote this sample program from the text and when I compile and run it, it just closes after the user inputs any number and presses enter. I’m guessing the answer to this is very obvious so forgive me as newbie here….it’s really my first C++ program 😛

#include <iostream>

using namespace std;

int main ()
{
  int numberOfLanguages;
  cout << "Hello Reader.\n"
       << "Welcome to C++.\n"

  cout << "How many programming languages have you used? ";
  cin  >> numberOfLanguages;

  if(numberOfLanguages < 1)
      cout << "Read the preface.  You may prefer.\n"
           << "a more elementary book by the same author.\n";
  else
      cout << "Enjoy the book.\n";

  return 0;
}
  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:27:03+00:00Added an answer on May 23, 2026 at 1:27 pm

    Imagine you were designing a model for application execution. You have two choices:

    A) When the end of a program is reached it shall terminate.

    B) When the end of a program is reached the program shall remain alive in some strange limbo state. It will still retain system resources and will not actually be doing anything, but in order to close the user must terminate it explicitly.

    I think anyone would go for option A here, and that is what you are seeing. The end of main is reached and your program exits.

    If you would like it to pause at the end take some input from the user, i.e.,

    char c;
    std::cin >> c;
    return 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just started learning Lisp and I can't figure out how to compile and
I just started learning JavaScript and am wondering why this simple snippet hangs when
I've just started learning about thread safety. This is making me code a lot
I've just started learning linq and lambda expressions, and they seem to be a
I have just started learning Erlang and am trying out some Project Euler problems
I'm just getting started with learning about Unit testing (and TDD in general). My
I have just started writing my own JavaScript Framework (just for the learning experience),
I just started using GNU Emacs as my text editor and I am concerned
I am learning OpenGL and just started getting into lighting. I enable lighting and
I've just started learning how to use the Entity Framework to write a very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.