Variable in C++

A variable can be known as a temporary container for storing information. The programmers are required different methods to store the data; variable provides different methods to work with numbers and value.


For e.g.

int q=18;

Where, q = variable name

Datatypes of Variable:

Variable have datatypes. On the base of that data types, memory allocations take place by operating system. Following are the list of datatype present in C++ programming language:

  • Character types
  • Integer types (signed)
  • Integer types (unsigned)
  • Floating-point types
  • Void type
  • Boolean type
  • Null pointer

A simple example of C++ Variable Program:

#include <iostream>

using namespace std;

int main() 


int x= 8;

int y=9;

int result =x*y;


return 0;



Leave a Reply

Notify of