Am I doing the variables right ( c++) ?

// very first c++ course using variables

#include
employing namespace an std;

int key ()

cout << any = SOME; b =4; any = a + A FEW; result = a – b;

Returning 0;

We have some problem understanding

Understanding C++
State variable scope
cout << any = SOME; // compiler:undefined a
fix with
int any;
cout << any = SOME;

Next
b=4; // compiler:undefined b
fix with
int b=4;

Up coming
end result = a – b; // compiler:undefined result
fix:
int end result = a – b;

will fix almost all errors

You cannot use parameters a, b, end result before declaring
The compiler wont know very well what the specifics should keep, whether integer, nature or the floating (double) value

That’s why before assigning all of them values, you should first declare them.That declaration will be simple.

If the variable should hold a strong integer(number), it needs to be declared as int varying;

Available for you it should be int a, b, end result; which means a, b, end result are with type int

That’s why your code should be

#include
employing namespace an std;
int key ()

int any, b, end result; //Declare that variables the, b, result
any = SOME; b =4; any = a + A FEW; result = a – b; //assign them the values
cout << "a value is "<<a<<"b worth is " << b <<"result is usually "<< consequence;
returning 0;

Leave a Reply