declare int c++ code example
Example 1: initialize int c++
// operating with variables
#include <iostream>
using namespace std;
int main ()
{
// declaring variables:
int a, b;
int result;
// process:
a = 5;
b = 2;
a = a + 1;
result = a - b;
// print out the result:
cout << result;
// terminate the program:
return 0;
}
Example 2: c++ declare variable
std::string str = "text"; // stores a string
int foo = 3; // stores any integer
float bar = 3.14; // stores 32 bit number
double baz = 3.14159265; // stores 64 bit number
Example 3: how to write int variable c++
//Declare integer variable in C++
int x;
//Initialize integer variable
x = 1;
//Declaring and Initialize in same line
int y = 0;