- C++ Course Basics
- C++ Tutorial
- C++ Basic Syntax
- C++ Identifiers
- C++ Character Set
- C++ Input/Output Operator
- C++ Variables
- C++ Data Types
- C++ Formatting Output
- C++ Operators
- C++ Assignment Operator
- C++ Type Conversion
- C++ Program Control
- C++ if and if-else
- C++ switch
- C++ loops
- C++ break and continue
- C++ Functions
- C++ Functions
- C++ Prototype and Definition
- C++ Function Call
- C++ Function Types
- C++ Friend Function
- C++ Function Overloading
- C++ Arrays and Strings
- C++ Arrays
- C++ One-Dimensional Arrays
- C++ Strings
- C++ String Functions
- C++ Structures
- C++ Structures
- C++ Nested Structure
- C++ Structure Array
- C++ Pass Structure to Function
- C++ Pointers
- C++ Pointers
- C++ Memory Map
- C++ Declare Initialize Pointers
- C++ Pointers and Structures
- C++ Object-Oriented
- C++ Object-Oriented
- C++ Classes and Objects
- C++ Constructors and Destructors
- C++ Objects as Function Arguments
- C++ Pointers and Objects
- C++ Data Structure
- C++ Linked List
- C++ Stack
- C++ Queues
- C++ File Handling
- C++ File Handling
- C++ Opening and Closing Files
- C++ Steps to Process Files
- C++ Sequential I/O Operations
- C++ Detecting EOF
- C++ File Pointers Random Access
- C++ Binary Files Operations
- C++ Error Handling
- C++ Misc
- C++ typedef
- C++ #define
- C++ Date and Time
- C++ Examples
- C++ Examples
- C++ Quiz
- C++ Quiz
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 */ #include<iostream.h> #include<conio.h> void main() { clrscr(); int i; float f; char c; double d; signed int si; unsigned int ui; cout<<"Enter any integer value: "; cin>>i; cout<<"You have "<<i; cout<<"\n\nEnter signed integer value: "; cin>>si; cout<<"You have "<<si; cout<<"\n\nEnter unsigned integer value: "; cin>>ui; cout<<"You have "<<ui; cout<<"\n\nEnter a floating-point value: "; cin>>f; cout<<"You have "<<f; cout<<"\n\nEnter a character: "; cin>>c; cout<<"You have "<<c; getch(); }
Here is the sample run of this C++ program:

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:
« Previous Tutorial Next Tutorial »
Follow/Like Us on Facebook
Subscribe Us on YouTube