I have a doubt when I run this code why int is 4 here ...? | Sololearn: Learn to code for FREE!

+1

I have a doubt when I run this code why int is 4 here ...?

https://www.sololearn.com/learning/2912/

10/22/2021 7:41:27 AM

Satyarth Mandil

11 Answers

New Answer

+4

So why it's is returning 4 ??

+2

Yes I had read ... But what is bytes and .. Why %ld is used ??

+2

Okkk thanks ...πŸ˜žπŸ˜žπŸ˜žπŸ˜”πŸ˜”

+2

Okk thanks for you help😊😊😊😊😊

+1

And how to I store values in it ...

+1

0

The code example on the first slide covers the use of `sizeof` operator. The `sizeof` operator returns number of bytes used (needed) to allocate a certain type, which is passed in as the operator's argument. https://en.cppreference.com/w/c/language/sizeof

0

Because an `int` type requires 4 bytes in memory (not a mandatory specification, but common). Did you read the page I linked?

0

Bro are you kidding me? you have 40+ codes but you say you don't know what a byte is? https://en.m.wikipedia.org/wiki/Bit https://en.m.wikipedia.org/wiki/Kibibytes About %ld, we call it format / conversion specifiers. It's used basically to describe which data type to be used when reading or printing data. http://www.cplusplus.com/reference/cstdio/scanf/ http://www.cplusplus.com/reference/cstdio/printf/

0

The C and C++ tutorials covers the basics on how to read, store and modify values. Please continue your C and C++ journey ...

0

Keep learning bro! πŸ’ͺ