- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the size of int, long type as per C++ standard?
Here we will see what are the sizes of the int and long type data in C++. The sizes are depending on the system architecture and the Operating system.
So in the 32-bit system, the standard is ILP32. In this standard the int, long and the pointer variables are of 32-bits.
For the 64-bit system there are two variations. For Linux Operating system the standard is LP64. Here long and pointer are of 64-bits, but int are of 32-bits. For the Windows operating system, the standard is LLP64. Here long long is 64-bit, but int and long are of 32-bits.
Example
#include <iostream> using namespace std; int main() { cout << "Size of int: " << sizeof(int) * 8 << " bits" << endl; cout << "Size of long: " << sizeof(long) * 8 << " bits" <<endl; cout << "Size of long long: " << sizeof(long long) * 8 << " bits"<< endl; }
Output
Size of int: 32 bits Size of long: 32 bits Size of long long: 64 bits
Advertisements