Mega Code Archive

 
Categories / C++ Tutorial / Language Basics
 

Assign value to a variable

#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"