Assign value to a variable : Variables « Language Basics « C++ Tutorial






#include <iostream> 
using namespace std; 
 
int main() 
{ 
  int length; // this declares a variable 
 
  length = 7; // this assigns 7 to length 
 
  cout << "The length is "; 
  cout << length; // This displays 7 
 
  return 0; 
}
The length is 7"








1.3.Variables
1.3.1.Assign value to a variable
1.3.2.Dynamic initialization.
1.3.3.A scoping example
1.3.4.Using the unary scope resolution operator
1.3.5.Finding maximum and minimum values for data types
1.3.6.Comparing data values