C++ Program to find the size of Int, Float, Char, and Double


In this program, You will learn how to find the size of Int, Float, Char, and Double Data Types in C++.


int Size:4

float Size:4

char Size:1

double Size:8

Example: How to find the size of Int, Float, Char, and Double Data Types in C++.

#include<iostream>
using namespace std;

int main() {

    int a, b, c, d;

    a = sizeof (int);
    b = sizeof (float);
    c = sizeof (char);
    d = sizeof (double);

    cout << "Size of int:" << a << endl;
    cout << "size of float:" << b << endl;
    cout << "size of char:" << c << endl;
    cout << "size of double:" << d << endl;

    return 0;
}

Output:

Size of int:4
size of float:4
size of char:1
size of double:8