### Starter Learner

Hey I'm New to C++ and was wondering about things :

2) what is voiding ?

3) cant understand this :

{
double d = 2.2;
int i=7;
d=d+i;
i=d*i;

}

if somebody could help me it would be great .

Thanks Guys .
1)When initializing a char you have to have the value in '' marks and it can only be one character or number.

2) voiding, not familiar with it being referred to as that, but it means (in functions) that the function doesn't return a value.
int add(int x, int y) { return x + y; }
void add(int x, int y) { std::cout << x + y << std::endl; }

3) Well data types are bool, char, int, float, double and double has the best precision. Types float and double are both used for decimals while int is for whole numbers (1, 2, 3, 4, etc.) and usually the compiler does any conversions for you (with some side effects).

How detailed you want this? That code is saying take a small speck of memory and label it d that will hold double values and then store 2.2 into it.
Take more memory, label it 'i' that holds int values and store 7 in it. This is where it gets fun. Take the value of d (2.2) and add it to i (7) and store the new value returned from that in d. Similarly, take the value of d (the new value of 2.2 + 7) and multiply it by 'i' (7) and store that new value in i.

Now the side effects is that going from int to float or double you will get decimals, but not the same with going the other way. If you go from double or float to int it will cut off the decimal and only give you the leading number. So if the answer was 0.342 and you store it in int, it will claim the answer is 0.

Don't know if I answered it well or just confused you more. Who knows I could be completely wrong on some or all of this.

[EDIT] Spellings and typos.
Last edited on by closed account z6A9GNh0
Thanks Man You Helped alot ! Thanks .
Topic archived. No new replies allowed.