I've just started learning C++, and I'm having some problems running my programs. Even when I just copy the source code from my C++ tutorial book:

// add.cpp
// Program for adding two whole numbers
#include <iostream>
using namespace std;
int main ()
    int number1;
    int number2;
    int sum;
    cout << "Write two whole numbers with a space between them: ";
    cin >> tall1 >> tall2;
    sum = tall1 + tall2;
    cout << "The sum is: " << sum << endl;
    return 0;
} // main

The program starts, and lets me type in two numbers, but when I hit 'enter' it shuts down and disappears.
(I use "Dev-C++" compiler)

Salem commented: Nice, code tags on the first post - keep up the good work :) +19

Recommended Answers

All 3 Replies

Thank you for using code tags, but The Member Rules state "Do not post threads with generic subjects such as "HELP ME" or "PROBLEM". Instead, clearly state a phrase describing the problem as the thread's title." Please post proper titles next time.

i would take a closer look at your variable names.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.