did i make a mistake by making result equal mpgh-mpgh2?
[help]C++ beginner noob # 2
//declaring variables
signed int mpgh1;
signed int mpgh2;
unsinged result (7);
// Process:
mpgh1 = 3;
mpgh2 = 1;
mpgh1 = mpgh1 + 3;
result = mpgh1 - mpgh2;
fixed it
signed int mpgh1;
signed int mpgh2;
unsinged result (7);
// Process:
mpgh1 = 3;
mpgh2 = 1;
mpgh1 = mpgh1 + 3;
result = mpgh1 - mpgh2;
fixed it

alright so ima sound like a dumb ass for this and im prob gunna have to go read up on declaring variables again, but did you assign result a value of 7, and then change it like you did with mpgh1 and 2?
Cause if you did it's a bit odd but i guess it works :B
also the signed and unsigned is good practise, but there's no actual input option and you made the result positive, so technically there's no point at all for a situation like this in a simple little program :3
Cause if you did it's a bit odd but i guess it works :B
also the signed and unsigned is good practise, but there's no actual input option and you made the result positive, so technically there's no point at all for a situation like this in a simple little program :3
OMG... it's soooo long. Remember to make code more shorter, like this:
When You're making signed int, there's no need to write signed int. Just int is enough.
I don't see any point of assigning value 7 to result.
Instead of mpgh1 = mpgh1 + 3; write mpgh1 += 3;. It's the same. You can make this for other mathematical operations (mpgh1 *= mpgh2 means this same what mpgh1 = mpgh1 * mpgh2).
If you will have any other questions, don't be afraid to ask.
Code:
//declaring variables
int mpgh1;
int mpgh2;
unsinged result;
// Process:
mpgh1 = 3;
mpgh2 = 1;
mpgh1 += 3;
result = mpgh1 - mpgh2;
I don't see any point of assigning value 7 to result.
Instead of mpgh1 = mpgh1 + 3; write mpgh1 += 3;. It's the same. You can make this for other mathematical operations (mpgh1 *= mpgh2 means this same what mpgh1 = mpgh1 * mpgh2).
If you will have any other questions, don't be afraid to ask.
lmao
You need to declare something for it to exist. And a declaration starts with a data type
int result = mpgh1; would work
If it is not declared the compiler won't know what result is.
Its the same as trying to go
int whitsPowerLevel = 8999
result = whitsPowerLevel
cout << &result
cant get the address of result if it doesnt exist
int result = mpgh1; would work
If it is not declared the compiler won't know what result is.
Its the same as trying to go
int whitsPowerLevel = 8999
result = whitsPowerLevel
cout << &result
cant get the address of result if it doesnt exist
az
but it different it just basic start like 6 line of code
not like he going far so the compiler would know
not like he going far so the compiler would know
Learn to speak english please.
And stop changing the subject.
If the type isn't declared, the computer wont know how much memory to allocate for the variable.
And a few months back i made a particle emitter, go find it
And in case you didnt know, C++ isnt just for trainers or engines.
And stop changing the subject.
If the type isn't declared, the computer wont know how much memory to allocate for the variable.
And a few months back i made a particle emitter, go find it
And in case you didnt know, C++ isnt just for trainers or engines.
