In this program, we will display a program to calculate the size of each data types with the help of C++ and Python.
C++ Program Calculate the size of each data types
#include<iostream.h>
#include< conio.h>
#include<stdio.h>
#include<math.h>
void main()
{
clrscr();
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);
getch();
}
Output:
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
Python Program Calculate the size of each data types
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))
Output
The size of integer is: 14
The size of float is: 16
The size of character is: 26
The size of complex is: 24
People are also reading:
- C++ and Python Code to Find The Sum of Elements Above and Below The Main Diagonal of a Matrix
- WAP in C++ & Python to Reverse a String
- WAP in C++ & Python for the Union of Two Arrays
- WAP in C++ & Python to transpose a Matrix
- WAP in C++ and Python to calculate 3X3 Matrix multiplication
- WAP in C++ and python to convert temperature from Fahrenheit to Celsius and vice-versa
- Write a C++ Calculator to perform Arithmetic Operations using Switch Case
- WAP in C++ & Python to reverse a number
- WAP to calculate the average marks of 5 subjects
- WAP in C++ & Python to Insert an Element in an Array
Leave a Comment on this Post