c++ program to find size of int, float, double and char

#include<iostream>
using namespace std;

int main() {
   cout << "Size of int: " << sizeof(int) << " bytes" << endl;
   cout << "Size of float: " << sizeof(float) << " bytes" << endl;
   cout << "Size of double: " << sizeof(double) << " bytes" << endl;
   cout << "Size of char: " << sizeof(char) << " byte" << endl;

   return 0;
}

This program calculates and displays the sizes of the int, float, double, and char data types in C++.

The #include<iostream> directive includes the necessary header file for input/output operations. The using namespace std statement allows us to use the cout and endl objects without explicitly specifying the std namespace.

The main() function is the entry point of the program.

The sizeof() operator is used to determine the size of a data type in bytes. It returns the number of bytes occupied by the given data type.

The cout object is used to display the results. The << operator is used to insert the values to be displayed, and the endl manipulator is used to insert a new line after each output.

The program prints the sizes of the int, float, double, and char data types using the cout statements. The sizeof() operator is used to calculate the size of each data type, and the results are displayed with appropriate labels.

Finally, the return 0; statement indicates that the program has executed successfully and returns a value of 0 to the operating system.