I have a doubt when I run this code why int is 4 here ...? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

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

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

22nd Oct 2021, 7:41 AM
Satyarth Mandil
Satyarth Mandil - avatar
11 Answers
+ 4
So why it's is returning 4 ??
22nd Oct 2021, 2:26 PM
Satyarth Mandil
Satyarth Mandil - avatar
+ 2
Yes I had read ... But what is bytes and .. Why %ld is used ??
22nd Oct 2021, 2:41 PM
Satyarth Mandil
Satyarth Mandil - avatar
+ 2
Okkk thanks ...😞😞😞😔😔
22nd Oct 2021, 3:05 PM
Satyarth Mandil
Satyarth Mandil - avatar
+ 2
Okk thanks for you help😊😊😊😊😊
22nd Oct 2021, 3:08 PM
Satyarth Mandil
Satyarth Mandil - avatar
+ 1
And how to I store values in it ...
22nd Oct 2021, 2:51 PM
Satyarth Mandil
Satyarth Mandil - avatar
+ 1
Do *
22nd Oct 2021, 2:51 PM
Satyarth Mandil
Satyarth Mandil - avatar
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
22nd Oct 2021, 7:52 AM
Ipang
0
Because an `int` type requires 4 bytes in memory (not a mandatory specification, but common). Did you read the page I linked?
22nd Oct 2021, 2:31 PM
Ipang
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/
22nd Oct 2021, 3:01 PM
Ipang
0
The C and C++ tutorials covers the basics on how to read, store and modify values. Please continue your C and C++ journey ...
22nd Oct 2021, 3:03 PM
Ipang
0
Keep learning bro! 💪
22nd Oct 2021, 3:06 PM
Ipang