The Display Size of the Different Data Type c++

find the datatypes of size like int, char, float, double, and String in the c++ program. It is a very basic program in c++

 int - 4 bytes

char - 1 bytes

float - 4 bytes

double - 8 bytes

program: -

#include <iostream>
using namespace std;

int main()
{
    cout << "The int " << sizeof(int) << " byte" << endl;
    cout << "The float " << sizeof(float) << " byte" << endl;
    cout << "The char " << sizeof(char) << " byte" << endl;
    cout << "The Double " << sizeof(double) << " byte" << endl;
    cout << "The String  " << sizeof(string) << " byte" << endl;
}

Post a Comment

0 Comments