Advertisement
dhiraj_bhakta

c++ datatype sizes

Aug 8th, 2024
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <limits>
  3. using namespace std;
  4.  
  5. int main() {
  6.   short s = 10;
  7.   int i = 10;
  8.   long l = 100;
  9.   long long ll = 10000;
  10.   float f = 10.00;
  11.   double d = 10.00;
  12.   long double ld = 10.00;
  13.   char c = 'a';
  14.   cout << "Size of short : " << sizeof(s) << endl;
  15.   cout << "Size of int : " << sizeof(i) << endl;
  16.   cout << "Size of long : " << sizeof(l) << endl;
  17.   cout << "Size of long long : " << sizeof(ll) << endl;
  18.   cout << "Size of float : " << sizeof(f) << endl;
  19.   cout << "Size of double : " << sizeof(d) << endl;
  20.   cout << "Size of long double : " << sizeof(ld) << endl;
  21.   cout << "Size of char : " << sizeof(c) << endl;
  22.   cout << numeric_limits<int>::max() << endl;
  23.   cout << numeric_limits<float>::max() << endl;
  24.  
  25.   return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement