Memory Consumption in long long vs int?

If I declare 2 global variables
int a[10000][10000] and long long b[10000][10000], will the both occupy same amount of memory initially? and after filling same values in both a and b will the amount of memory used by both be equal?

No don’t declare 2d array of long long , it will give u memory limit exceed.

1 Like

does it use more memory that 2d int array ??

Yes obviously , size of long long int is 8 bytes, int has 4 byte.

[~/devel/hackerrank/otherpeoples]>cat blah23.cpp 
#include <iostream>
using namespace std;

int a[10000][10000];
long long b[10000][10000];

int main() 
    cout << "sizeof a: " << sizeof(a) << endl;
    cout << "sizeof b: " << sizeof(b) << endl;
[~/devel/hackerrank/otherpeoples]>g++ blah23.cpp -O3 -g3 -Wall -Wextra
sizeof a: 400000000
sizeof b: 800000000

Ohh Right! Thank you

Got It! Thanks…btw nice representation.


almost one week before I was trying some A question on CF and I take long long 2d array , and it give me memory limit exceed , I m like WTH how memory limit exceed then I get to know this .