issue with integer and double values

Write your question here.

I am confused about DOUBLE does that mean that number1 should double based on I enter?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

using namespace std;
int main ()

}

double a;
int b;
int c = a+b;

cout <<"enter number1:";
cin >> a;

cout <<"enter number2:";
cin>> b;

c= a+b;
cout<<c;




    return 0;
}







  Put the code you need help with here.
Last edited on
>I am confused about DOUBLE does that mean that number1 should double based on I enter?

No, double is a type, just like int, float, etc. see documentation here: http://www.cplusplus.com/doc/oldtutorial/variables/

To make it short, the difference between an int and a double is that the int is an number that is round, that is without a comma. A double can be round but can also have multiple digits after the comma.
double is one of the 'dumb keywords' left over from days of yore back when we programmed on rocks with chisels. It is double the size of a float, hence the name. Float's name isn't really awesome either (it stands for floating point which is a reference to the mechanics of how decimal numbers are handled); its right on up there with word or the ever popular long long. You get used to the bad type names, but they are strange when you first see them :) Doubles are for decimal numbers (like pi or e or the sqrt of 2) and integers are for (1,2,3,4...) 'whole' numbers.

Hoogo, half the world things pi is 3,14 and the other half thinks its 3.14. :) Commas depend on where you live.

Last edited on
Thank you for your prompt reply
@jonnin haha I know right, in my country we use commas, however since I learned english and use it most of the time, I find commas really handy to separate big numbers such as 1,200 -- which if you went to school where I live, would equate to 1.2. But the 'point' I wanted to get across (no pun intended) was what you said. The word decimal should have come to mind but didn't, it explains it much better I guess :)
Topic archived. No new replies allowed.