+ 1
Int Variable memory
How many bytes should we consider for int Variable in solo learn quiz in C++ language ? 2 or 4
16 Respostas
+ 6
Malik Hamza Nawaz read this thread for a more complete answer and I think it will help.
https://www.sololearn.com/Discuss/650635/?ref=app
+ 4
Malik Hamza Nawaz
Based on what you wrote with no real explanation I'm going to say 2
+ 3
Malik Hamza Nawaz Then my previous answer should be 4 and Ipang answered that in the thread Mentioned above.
generally it is 2 with pointer 4 as @sayan mentioned
+ 3
Ipang That was what Malik Hamza Nawaz mentioned above
"Yes agreed so what is the architecture of solo learn compiler?"
+ 2
Malik Hamza Nawaz
It's not about in SoloLearn quiz or other place. Size of a type depends on language, compiler implementation (for compiled languages), and system architecture (a 16, 32 or 64bit machine).
I think you may need to specify a relevant language in your thread tags, just to improve context clarity đ
+ 2
Malik Hamza Nawaz
In regards to C or C++, the standards does not specify a strict definition. IIRC there is however a specification that defines that (cmiiw) size of
char < short < int <= long < long long
When it comes to size of integral types family.
P.S. It is highly recommended to rely on `sizeof` operator rather than assumptions on type sizes : )
+ 1
Yes agreed so what is the architecture of solo learn compiler?
+ 1
Malik Hamza Nawaz
Although I am not exactly sure, but considering today's demands of the SoloLearn platform, I would guess it uses 64bit machines. 32bit machines serving millions of users may require more work. 16bit machines may not even be capable.
Still, would you mind specify a language in tags above?â
+ 1
BroFar
Sir, my answer in that thread was solely based on Code Playground nature. In the end we know we better off to rely on `sizeof` operator : )
+ 1
4 bytes
+ 1
4 bytes
+ 1
You can dry run a code in SoloLearn ide. Use sizeof() to get your answer.
Although it depends on the question contributor. Generally now a days we use 4 byte for int.
0
Yes but now in 64 bit architecture the size is 4 bits
0
Oh sorry I forgot to mention that. I am considering C++
0
Thank you all.