i've tried practically anything and everything, adding and removing semi-colons, setting the value to int, setting it to float, removing it in and it of the damn int main(int nNumberofArgs, char* pszArgs[]), but nothing works! please, help! this is my code;
// this program will add the number 2 to any other number, pretty
// fucking simple, right? no, not fucking simple.
//
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
int a;
int b;
int c;
a = 2;
c = 2+b;
cout << "Hey! this program adds 2 to anything! SIMPLE!" << endl;
cout << "Please enter any random number:" << endl;
cout << "your number plus 2";
cin << b;
cout << c << endl;
system ("PAUSE");
return 0;
}
Input is done using >>, so cin >> b;
Also, C++ is an imperative language, so order matters and you have to perform the addition after the values are known.
#include <iostream>
#include <cstdio>
#include <cstdlib>
usingnamespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
int a;
int b;
int c;
a = 2;
c = 2+b;
cout << "Hey! this program adds 2 to anything! SIMPLE!" << endl;
cout << "Please enter any random number:" << endl;
cout << "your number plus 2";
cin << b;
cout << c << endl;
system ("PAUSE");
return 0;
}
int main()
{
int a;
int b;
int c;
a = 2;
cout << "Hey! this program adds 2 to anything! SIMPLE!" << endl;
cout << "Please enter any random number:" << endl;
cout << "your number plus 2";
cin >> b; //cin is this way >>
//add them after getting user input
//also, using 'a' because it equals 2, like your code
//but you never use it!
c = a + b;
cout << c << endl;
//press any key to exit...
std::cout << "\n\nPress any key to exit...";
while( ! _kbhit() )
{ /* do nothing - wait for key press */ }
return 0;
}