Declaring Integer type Variable and storing Values in C++ programming
Integer type Variable:
To store an integer type value we first declare a variable by using int
and then stores an integer value in that variable.
Actually int means integer type variable
For example if we want to store 2 to a variable we will
write the following program.
#include < iostream >
using namespace std;
int main()
{
int a;
a=2;
return 0;
}
To display integer value stores in variable:
And if you want to display this on compiler , write the following program
#include < iostream >
using namespace std;
int main()
{
int a;
a=2;
cout << a << endl;
return 0;
}
In this program the compiler will show 2 because we stored this on variable a
Also We never uses " around a this is the reason that it will show 2 as output.
If we use inverted commas " around a the compiler will show a as output.
Comments
Post a Comment