C++ Example – Check the Size of int, float, double, and char Variables
C++ Example – Check the Size of int, float, double, and char Variables | Tutorial
Tutorial – Learning is not just about technology, but also about dreams!
- Home
- HTML
- JavaScript
- CSS
- Vue
- React
- Python3
- Java
- C
- C++
- C#
- AI
- Go
- SQL
- Linux
- VS Code
- Bootstrap
- Git
- Local Bookmarks
C++ Tutorial
C++ Tutorial C++ Introduction C++ Environment Setup C++ Basic Syntax C++ Comments C++ Data Types C++ Variable Types C++ Variable Scope C++ Constants C++ Modifier Types C++ Storage Classes C++ Operators C++ Loops C++ Decision Making C++ Functions C++ Numbers C++ Arrays C++ Strings C++ Pointers C++ References C++ Date & Time C++ Basic Input/Output C++ struct C++ vector Container C++ Data Structures
C++ Object-Oriented
C++ Classes & Objects C++ Inheritance C++ Overloading Operators and Functions C++ Polymorphism C++ Data Abstraction C++ Data Encapsulation C++ Interfaces (Abstract Classes)
C++ Advanced Tutorial
C++ Files and Streams C++ Exception Handling C++ Dynamic Memory C++ Namespaces C++ Templates C++ Preprocessor C++ Signal Handling C++ Multithreading C++ Web Programming
C++ Resources
C++ STL Tutorial C++ Import Standard Library C++ Standard Library C++ Useful Resources C++ Examples C++ Quiz <a href="#" title="C++ Standard Input/Output – ">C++ <a href="#" title="C++ File Input/Output Library – ">C++ <a href="#" title="C++ Standard Library ">C++ <a href="#" title="C++ Standard Library ">C++ <a href="#" title="C++ Container Class ">C++ <a href="#" title="C++ Container Class ">C++ <a href="#" title="C++ Container Class ">C++ <a href="#" title="C++ Container ">C++ <a href="#" title="C++ Container Class ">C++ <a href="#" title="C++ Container Class ">C++ <a href="#" title="C++ Container Class ">C++ <a href="#" title="C++ Container Class ">C++ <a href="#" title="C++ Container Class ">C++ <a href="#" title="C++ Container Class ">C++ <a href="#" title="C++ Container Class
Deep Dive
Scripts
Development Tools
Scripting Languages
Computer Science
Web Design & Development
Programming Languages
Web Service
Network Services
Programming
Software
C++ Example - Check the Size of int, float, double, and char Variables
Use the C++ sizeof operator to calculate the space occupied by int, float, double, and char variables.
sizeof operator syntax:
sizeof(dataType);
Note: The results may vary on different systems.
Example
#include<iostream>
using namespace std;
int main()
{
cout << "char: " << sizeof(char) << " bytes" << endl;
cout << "int: " << sizeof(int) << " bytes" << endl;
cout << "float: " << sizeof(float) << " bytes" << endl;
cout << "double: " << sizeof(double) << " bytes" << endl;
return 0;
}
The output of the above program is:
char: 1 bytes
int: 4 bytes
float: 4 bytes
double: 8 bytes
YouTip