Advertisement
Subrata_Nandi

Datatypes

Sep 19th, 2023
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int a; // declaration
  6.     a=12; // initialisation
  7.  
  8.     cout<<"size of int "<<sizeof(a)<<endl;
  9.  
  10.     float b;
  11.     cout<<"size of float "<<sizeof(b)<<endl;
  12.  
  13.     char c;
  14.     cout<<"size of char "<<sizeof(c)<<endl;
  15.  
  16.     bool d;
  17.     cout<<"size of bool "<<sizeof(d)<<endl;
  18.  
  19.     short int si;
  20.     long int li;
  21.     cout<<"size of short_int "<<sizeof(si)<<endl;
  22.     cout<<"size of long_int "<<sizeof(li)<<endl;
  23.  
  24.     return 0;
  25. }
  26.  
  27. //Output
  28.  
  29. size of int 4
  30. size of float 4
  31. size of char 1
  32. size of bool 1
  33. size of short_int 2
  34. size of long_int 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement