+ 1

Int Variable memory

How many bytes should we consider for int Variable in solo learn quiz in C++ language ? 2 or 4

28th Aug 2020, 1:48 AM
Hamza Malik
Hamza Malik - avatar
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
28th Aug 2020, 2:24 AM
BroFar
BroFar - avatar
+ 4
Malik Hamza Nawaz Based on what you wrote with no real explanation I'm going to say 2
28th Aug 2020, 2:21 AM
BroFar
BroFar - avatar
+ 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
28th Aug 2020, 2:51 AM
BroFar
BroFar - avatar
+ 3
Ipang That was what Malik Hamza Nawaz mentioned above "Yes agreed so what is the architecture of solo learn compiler?"
28th Aug 2020, 3:19 AM
BroFar
BroFar - avatar
+ 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 👍
28th Aug 2020, 2:37 AM
Ipang
+ 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 : )
28th Aug 2020, 2:54 AM
Ipang
+ 1
Yes agreed so what is the architecture of solo learn compiler?
28th Aug 2020, 2:38 AM
Hamza Malik
Hamza Malik - avatar
+ 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?☝
28th Aug 2020, 2:46 AM
Ipang
+ 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 : )
28th Aug 2020, 2:55 AM
Ipang
+ 1
4 bytes
29th Aug 2020, 9:58 AM
MisterCube
MisterCube - avatar
+ 1
4 bytes
29th Aug 2020, 11:20 AM
Mahmoud Mahanny
Mahmoud Mahanny - avatar
+ 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.
29th Aug 2020, 3:09 PM
Bibhash Ghosh
Bibhash Ghosh - avatar
0
Yes but now in 64 bit architecture the size is 4 bits
28th Aug 2020, 2:22 AM
Hamza Malik
Hamza Malik - avatar
0
Oh sorry I forgot to mention that. I am considering C++
28th Aug 2020, 2:46 AM
Hamza Malik
Hamza Malik - avatar
0
Thank you all.
30th Aug 2020, 8:37 AM
Hamza Malik
Hamza Malik - avatar