C++ Variable Types

In C++, a variable is basically a named storage that our programs can manipulate. Each and every variable in C++ has particular type, determines the layout and size of the memory of the variable, and the value's range that can be stored within that memory.

C++ Variable Type Example

Here is an example, uses many types of variables in C++:

/* C++ Variable Types */

void main()

   int i;
   float f;
   char c;
   double d;
   signed int si;
   unsigned int ui;

   cout<<"Enter any integer value: ";
   cout<<"You have "<<i;
   cout<<"\n\nEnter signed integer value: ";
   cout<<"You have "<<si;
   cout<<"\n\nEnter unsigned integer value: ";
   cout<<"You have "<<ui;
   cout<<"\n\nEnter a floating-point value: ";
   cout<<"You have "<<f;
   cout<<"\n\nEnter a character: ";
   cout<<"You have "<<c;


Here is the sample run of this C++ program:

c++ variable types

C++ also allows to define various other types of variables, which we will cover in subsequent chapters like pointers, arrays, references, structures, and class, etc.

More Examples

Here are some more C++ programs listed, that you may like:

C++ Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube