How we can get the size of an array in c .... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How we can get the size of an array in c ....

{20,50,60,70,80}

5th Nov 2020, 1:01 PM
Vikramjeet Singh
Vikramjeet Singh - avatar
5 Answers
+ 8
sizeof(array)/sizeof(array[0]) , you could have Google that as well
5th Nov 2020, 1:04 PM
Abhay
Abhay - avatar
+ 4
Hey buddy, To determine the size of your array in bytes, you can use the sizeof operator: Sizeof() : It returns the size of a variable. For example, Int array[5]; Sizeof (array);
5th Nov 2020, 4:47 PM
KRITI
KRITI - avatar
+ 2
If you have int array [5]; The size of the array is sizeof( array ); that is equal to sizeof( array[0] ) * 5; The length of your array is just 5 because you declared so. in general you can find the length doing sizeof( array ) / sizeof( array[0] );
5th Nov 2020, 1:29 PM
Davide
Davide - avatar
+ 1
Ok i got it thankyou so much....🙏
5th Nov 2020, 1:48 PM
Vikramjeet Singh
Vikramjeet Singh - avatar
0
Ok bro..... but i want this answer arr[5] This size 5 kese aayega 5 yeh
5th Nov 2020, 1:11 PM
Vikramjeet Singh
Vikramjeet Singh - avatar