# Simple Calculator Help

Page 1 of 1

## 5 Replies - 708 Views - Last Post: 01 October 2012 - 07:07 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=293871&amp;s=b0b22d21305cc9457a9a74e14e13bd11&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 David7823

• New D.I.C Head

Reputation: 1
• Posts: 4
• Joined: 01-October 12

# Simple Calculator Help

Posted 01 October 2012 - 01:46 PM

Hello!
I made a simple calculator but I can only use one digit numbers???
For example I can add 1 + 2 but not 11 + 22? I am new to c++ so i'm not sure what to do.

Here is my code:
```#include <iostream>
using namespace std;
int main()
{
int a;
int b;
int sum;

cout << "Enter a number: \n";
cin >> a;

cout << "Enter another number: \n";
cin >> b;

sum = a + b;

cout << "The answer is " << sum << endl;

return 0;
}

```

Is This A Good Question/Topic? 0

## Replies To: Simple Calculator Help

### #2 #define

• Duke of Err

Reputation: 1615
• Posts: 5,662
• Joined: 19-February 09

## Re: Simple Calculator Help

Posted 01 October 2012 - 02:04 PM

That's strange usually int's can hold 10's of thousands. Do you get an error after you enter 11 and 22?

### #3 David7823

• New D.I.C Head

Reputation: 1
• Posts: 4
• Joined: 01-October 12

## Re: Simple Calculator Help

Posted 01 October 2012 - 02:06 PM

Nope. I simply can't type more than one digit into Xcode?

### #4 David7823

• New D.I.C Head

Reputation: 1
• Posts: 4
• Joined: 01-October 12

## Re: Simple Calculator Help

Posted 01 October 2012 - 02:14 PM

It must be an Xcode problem. I exported it and ran it in terminal and it works just fine.

### #5 Midi_

Reputation: 9
• Posts: 110
• Joined: 22-May 12

## Re: Simple Calculator Help

Posted 01 October 2012 - 06:52 PM

your program should work, are you using an xcode c++ file? thats strange man

### #6 Skydiver

• Code herder

Reputation: 4248
• Posts: 13,585
• Joined: 05-May 12

## Re: Simple Calculator Help

Posted 01 October 2012 - 07:07 PM

Out of curiosity, what result are you seeing when you enter 11 as the first number and 22 as the second number?

Is the result some wacky number? Is it always 0?