sizeof() keyword in C++ by R4R Team

sizeof() i C++ :
-This is the function that return the size of the any data_type.

syntax:
sizeof(variable);

Example-
sizeof(int) //4
sizeof(char) //1

program:

#include < iostream>
using namespace std;
int main()
{
int num;
char s='2';
float k=3.21;
double d=2.897;
cout<<"Size of int: "<< sizeof(num)<< endl;
cout<<"Size of char: "<< sizeof(s)<< endl;
cout<<"Size of float: "<< sizeof(k)<< endl;
cout<<"Size of double: "<< sizeof(d)<< endl;
return 0;
}


output-

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




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!