C++ programming

Jedired1

Member
can anyone here help me ?

what have i done wrong with this code ?
#include <iostream>
using namespace std;
int main()
{
cout << "Welcome to magic maths" << endl;
cout << "IM a C++ programmer" << endl;
int Number;
int result;
cout << "Please say your number" << endl;
cin >> Number;
cout <<"Try and work out how i got from your number to this .... "<< endl;
result = 10 * 2;
cin >> result;
cout << "was this your number? " << endl;
}
 

Voltage

Puzzlemaster
I don't think he's asking for a tutorial on C++, but some assistance with just that one code he mentioned.
Thou I cant help you myself, as I wont probably be learning C++ till next year.
 

WildFire

Warrior of Linux
Being serious this time: You haven't actually told us what kind of bug the program has, does it fail to start or is it a logical problem (where the program runs, but does not do the thing you intended but continues to run)
 

Triad

Legions Developer
The function returns an integer which is why you have "int main()". So, you need to return one, and since it is the main function, you should return 0 so the operating system knows that there were no errors.
 

Jedired1

Member
nvm i ve done it myself :p thanks again for interest
and if u want to try Magic Maths :DDDD here is the code!!!
#include <iostream>

using namespace std;
int main()
{
cout << "Welcome to magic maths" << endl;
int Number;
int result;
cout << "Please say your number" << endl;
cin >> Number;
cout << Number + 20 *2 -5 << endl;
cout <<"Try and work out how i got from your number to this .... "<< endl;
return 0;
}
* good for practicing arithmetic series*
 

WildFire

Warrior of Linux
Wooo i figured it out :D but can someone tell me how i can make it not only add 20 but time it by 2 as well ?

You have logical operators and relationship operators. Logical:

+ Addication
- Subtraction
* Multiple
/ Division

cba to list everything, go google it.
 

Jedired1

Member
You have logical operators and relationship operators. Logical:

+ Addication
- Subtraction
* Multiple
/ Division

cba to list everything, go google it.

my problem was weirdly i did *number(space)+ 20(space)*(space)2* ..... it was supposed to be *number(space)+20(space)*2(space)..(next variable)*
 
Top