Write a program in C++ & Python to calculate the size of each data types

By | July 2, 2019

In this program, we will display the size of each pre-defined data type present in C++ and python.


#include< conio.h>

void main()
cout<<"The size of integer is: "<<sizeof(1);
cout<<"\nThe size of float is: "<<sizeof(1.1);
cout<<"\nThe size of Character is: "<<sizeof('a');
cout<<"\nThe size of long int is: "<<sizeof(long);
cout<<"\nThe size of Double is: "<<sizeof(double);


The size of integer is: 2
The size of float is: 8
The size of character is: 1
The size of long is: 4
The size of Double is: 8


import sys
print("The size of integer is:",sys.getsizeof(1))
print("The size of float is:",sys.getsizeof(1.0))
print("The size of character is:",sys.getsizeof('a'))
print("The size of complex is:",sys.getsizeof(1+2j))


The size of integer is: 14
The size of float is: 16
The size of character is: 26
The size of complex is: 24

Leave a Reply

Your email address will not be published. Required fields are marked *