Main help: What is wrong with this C++ program? - Help.com



This post left anonymously

What is wrong with this C++ program?

Why does it crash before it loads?

// Fig. 2.5: fig02_05.cpp
// Addition program that displays the sum of two integers.
#include iostream> // allows program to perform input and output

// function main begins program execution
int main()
{
// variable declarations
int number1; // first integer to add
int number2; // second integer to add
int sum; // sum of number1 and number2

std::cout “Enter first integer: “; // prompt user for data
std::cin >> number1; // read first integer from user into number1

std::cout “Enter second integer: “; // prompt user for data
std::cin >> number2; // read second integer from user into number2

sum = number1 + number2; // add the numbers; store result in sum

std::cout “Sum is ” sum std::endl; // display sum; end line

return 0; // indicate that program ended successfully

} // end function main

This open post was written 1 year ago | V/U/S: 85, 1, 2 | Edit Post | Leave a reply | Report Post


Reciprocity (0) Reciprocation Failure -- The poster has NOT helped anyone else yet!

Since writing this post Anonymous may have helped people, but has not within the last 4 days.

Post Tags (10)

Replies (1)

Where were you?

Click and drag to move the map around. FAQ: How we place people on this map »
You can also watch events on Help.com as they happen
Mouse over the map for 2 seconds to see an expanded, interactive view

tricky offline Verified User (3 years) Long Term User Shouts: 40 #
An Unknown Location | 1 year ago (2 minutes after post)

instead of using std:: try writing before the main

using namespace std;

or osmething like that :D i havent written C++ for some time now

Quote this reply Report this reply to moderators
Help me with: What If?

Invite Others to Help

A logged in and verified Help.com member has the ability to setup a Friends List and invite others to help with posts.