How many bytes should we consider for int Variable in solo learn quiz in C++ language ? 2 or 4
8/28/2020 1:48:51 AM
Hamza Malik16 Answers
New AnswerMalik Hamza Nawaz read this thread for a more complete answer and I think it will help. https://www.sololearn.com/Discuss/650635/?ref=app
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
Ipang That was what Malik Hamza Nawaz mentioned above "Yes agreed so what is the architecture of solo learn compiler?"
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 👍
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 : )
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?☝
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 : )
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.
SoloLearn Inc.
4 Embarcadero Center, Suite 1455Send us a message