C++ Program to Find the Size of int, float, double and char Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Try it on GfG Practice In this article, we will learn to write a C++ program to find the size of int, float, double, and char. It is important to know the size of different data types especially when working with large datasets to optimize memory usage. The size of a variable can be determined using sizeof() operator in C++. The syntax of size of operator is: sizeof(dataType); To find the size of the four datatypes: The four types of variables are defined as integerType, floatType, doubleType, and charType.The size of the variables is calculated using the sizeof() operator.C++ Program to Find the Size of a Data Types C++ // C++ program to find the size of int, char, // float and double data types #include <iostream> using namespace std; int main() { int integerType; char charType; float floatType; double doubleType; // Calculate and Print // the size of integer type cout << "Size of int is: " << sizeof(integerType) << "\n"; // Calculate and Print // the size of doubleType cout << "Size of char is: " << sizeof(charType) << "\n"; // Calculate and Print // the size of charType cout << "Size of float is: " << sizeof(floatType) << "\n"; // Calculate and Print // the size of floatType cout << "Size of double is: " << sizeof(doubleType) << "\n"; return 0; } OutputSize of int is: 4 Size of char is: 1 Size of float is: 4 Size of double is: 8 Complexity AnalysisTime complexity: O(1)Auxiliary space: O(1)Data Types with Their Size, Range, and Format Specifiers Here is a list of all the data types with their size, range and format specifiers: Data TypeMemory (bytes)RangeFormat Specifiershort int2 -32,768 to 32,767%hd unsigned short int2 0 to 65,535%hu unsigned int4 0 to 4,294,967,295%u int4 -2,147,483,648 to 2,147,483,647%d long int4 -2,147,483,648 to 2,147,483,647%ld unsigned long int4 0 to 4,294,967,295%lu long long int8 -(2^63) to (2^63)-1%lld unsigned long long int8 0 to 18,446,744,073,709,551,615%llu signed char1 -128 to 127%c unsigned char1 0 to 255%c float4 1.17549e-38 to 3.40282e+38%f double8 2.22507e-308 to 1.79769e+308%lf /tbody> C++ Program to Find the Size of int, float, double and char Comment More infoAdvertise with us Next Article Interview Preparation For Software Developers R RishabhPrabhu Follow Improve Article Tags : C++ Programs C++ C Basic Programs Practice Tags : CPP Similar Reads Interview PreparationInterview Preparation For Software DevelopersMust Coding Questions - Company-wise Must Do Coding Questions - Topic-wiseCompany-wise Practice ProblemsCompany PreparationCompetitive ProgrammingSoftware Design-PatternsCompany-wise Interview ExperienceExperienced - Interview ExperiencesInternship - Interview ExperiencesPractice @GeeksforgeeksProblem of the DayTopic-wise PracticeDifficulty Level - SchoolDifficulty Level - BasicDifficulty Level - EasyDifficulty Level - MediumDifficulty Level - HardLeaderboard !!Explore More...Data StructuresArraysLinked ListStackQueueBinary TreeBinary Search TreeHeapHashingGraphAdvance Data StructuresMatrixStringAll Data StructuresAlgorithmsAnalysis of AlgorithmsSearching AlgorithmsSorting AlgorithmsPattern SearchingGeometric AlgorithmsMathematical AlgorithmsRandomized AlgorithmsGreedy AlgorithmsDynamic ProgrammingDivide & ConquerBacktrackingBranch & BoundAll AlgorithmsProgramming LanguagesCC++JavaPythonC#Go LangSQLPHPScalaPerlKotlinWeb TechnologiesHTMLCSSJavaScriptBootstrapTailwind CSSAngularJSReactJSjQueryNodeJSPHPWeb DesignWeb BrowserFile FormatsComputer Science SubjectsOperating SystemsDBMSComputer NetworkComputer Organization & ArchitectureTOCCompiler DesignDigital Elec. & Logic DesignSoftware EngineeringEngineering MathematicsData Science & MLComplete Data Science CourseData Science TutorialMachine Learning TutorialDeep Learning TutorialNLP TutorialMachine Learning ProjectsData Analysis TutorialTutorial LibraryPython TutorialDjango TutorialPandas TutorialKivy TutorialTkinter TutorialOpenCV TutorialSelenium TutorialGATE CSGATE CS NotesGate CornerPrevious Year GATE PapersLast Minute Notes (LMNs)Important Topic For GATE CSGATE CoursePrevious Year Paper: CS exams Like