Counting Array Elements using sizeof() Operator

Поділитися
Вставка
  • Опубліковано 4 січ 2025

КОМЕНТАРІ • 104

  • @anuragpimpalkar3867
    @anuragpimpalkar3867 4 роки тому +57

    You are a real gem. We need more teachers like you.
    Thank you.

  • @ysailokesh
    @ysailokesh 4 роки тому +42

    u r great man who can attract most of the students by your words

  • @tayyab.sheikh
    @tayyab.sheikh 11 місяців тому +7

    You just wrote 152 elements only to show us how the sizeof operator works!
    Really admirable ❤

  • @palakgoyal7921
    @palakgoyal7921 3 роки тому +9

    Happy teacher day sir
    Thanku to make learning C so simple

  • @sohelansari-dq5kv
    @sohelansari-dq5kv 4 роки тому +8

    no no sir we are not angry with you...we just love you ..the best teacher

  • @ayushpawar1512
    @ayushpawar1512 3 роки тому +3

    Amazing video Sir, very easy to understand not only this, but whole playlist...Thank you.

  • @mugheesahmed588
    @mugheesahmed588 Рік тому

    Genius men You are amazing love you got a follower, this show how much complex universities had made in some they don't even tell you this amazing man once again❤❤❤❤

  • @mellymathers2548
    @mellymathers2548 5 років тому +5

    very understanding video.thank you!

  • @dipeshsamrawat7957
    @dipeshsamrawat7957 3 роки тому +3

    I love Neso Academy 💝.

  • @streamxlous5334
    @streamxlous5334 3 роки тому +1

    straight to the point !! nice one!!

  • @patrickmccarthy7124
    @patrickmccarthy7124 Рік тому

    Thank you so much! I was really struggling to understand summing arrays coming from python to c++, but you cleared it up perfectly!

  • @_iamankitt_
    @_iamankitt_ 3 роки тому +1

    Tussi great ho brother! 🙏🙌🏻

  • @kayamtejaswi22
    @kayamtejaswi22 3 роки тому +1

    Clear explained all videoes

  • @P.V.SBharadwaj
    @P.V.SBharadwaj Місяць тому

    Super bro I understand clearly thank you bro

  • @mauryaashish1865
    @mauryaashish1865 4 роки тому +1

    U r too good sir!!!

  • @mishkathossain2984
    @mishkathossain2984 4 роки тому +1

    You guys are the beast

  • @Make_it-Simple
    @Make_it-Simple 7 місяців тому

    thumbs up for simple and easy explanation

  • @joeboehaha
    @joeboehaha 11 місяців тому

    this guy is a genius

  • @krutarthpatel6537
    @krutarthpatel6537 3 роки тому +2

    W........o.........w .........just wow 👏 what a explanation 🤩!!

  • @ecoholic84
    @ecoholic84 Рік тому

    Awesome video

  • @mishkathossain2984
    @mishkathossain2984 4 роки тому +1

    Thanks again

  • @tomasprejda4165
    @tomasprejda4165 2 роки тому +2

    I am normally using Python, but I would like to learn C++ as well.
    Let's say I would like to create a function which would iterate through an array of integers:
    1. I declare the function ahead... int arrayIterator(*int arrayInput) with a pointer to the array as an argument.
    2. In the int main() function I declare an array and then pass it into the function arrayIterator.
    3. The function arrayIterator under main function has a for loop, I would like to iterate through each element of the array.
    To iterate through each element with a for loop, I need to know the size of the array. How do I get it from outside the main function? Is it even possible? The only way which worked and I came up with was to pass the size as a second argument (sizeof(arrayInput) / sizeof(arrayInput[0]))

  • @aryanrasaily8252
    @aryanrasaily8252 3 роки тому +4

    instead of writing designated array element can we also write :
    size of an array=sizeof(a)/sizeof(int); ?
    Considering the whole program is based on integer data type, so a particular array may have a size of 4bytes i.e., same size, size of int a[o]=int.

    • @knowledge3481
      @knowledge3481 Рік тому

      Yes you can, but in this case it would work only with integer type numbers. When you use the "arr[0]", you generalize it so you can use with whatever kind of type you want.

  • @iron.addiction
    @iron.addiction Рік тому

    this is fun to study wow

  • @badrkarrachai1189
    @badrkarrachai1189 4 роки тому +1

    that is veary helpfull thanks

  • @18MSchaudhary04
    @18MSchaudhary04 Рік тому

    really good lecture ..

  • @karymefatimacrisologo3208
    @karymefatimacrisologo3208 2 роки тому

    thank youu😭😭😭😭😭

  • @Baller1412
    @Baller1412 Рік тому

    thank you

  • @wordofgodisliving
    @wordofgodisliving 2 роки тому

    Thanking you sir

  • @shreedharchavan7033
    @shreedharchavan7033 3 роки тому

    Excellent

  • @andis6852
    @andis6852 4 роки тому +1

    Thank you!!!

  • @muskaan1537
    @muskaan1537 4 роки тому +1

    Good

  • @devpatel8109
    @devpatel8109 3 роки тому

    Thanks a lot sir...giving us a great content

  • @Vivekanand_06
    @Vivekanand_06 8 місяців тому

    Why didn't sizeof(array name) return 8bytes as array name is same as pointer to the first element of the array and when we give address as operand to sizeof operator it must return 8 bytes

  • @kgfchapter2328
    @kgfchapter2328 3 роки тому +1

    what about ZEROES in array .........
    because a[ ]= {10} , now array element in becomes - {0,0,0,0,0,0,0,0,0,10} because as sir said in previous video rest of the element becomes 0....
    now what is aize of array becomes.............................
    TOTALLY CONFUSED 😕 ........

  • @anilptl9950
    @anilptl9950 4 роки тому +1

    size of int 2 bytes

  • @saruulnasanjargal8590
    @saruulnasanjargal8590 2 роки тому

    U're awesome! thank you very much

  • @abhishek2116
    @abhishek2116 3 роки тому

    i am pretty confuse after watching this this is what i have confusion-reason--
    # include
    void print(int arr[])
    {
    int n = sizeof(arr)/sizeof(arr[0]);
    int i;
    printf("%d
    ",n); //8(32/4)
    for (i = 0; i < n; i++)
    printf("%d ", arr[i]);
    }
    int main()
    {
    int arr[] = {1, 2, 3, 4, 5, 6, 7, 8};
    // but print only arr[0],arr[1] as {1,2} but accroding to your content answer should be {1,2,3,4,5,6,7,8} as whole array
    print(arr);
    return 0;
    }

  • @erkein1092
    @erkein1092 4 роки тому

    cool trick, thanks

  • @satyamsahoo9396
    @satyamsahoo9396 4 роки тому

    THANKS, A LOT SIR

  • @AnshumanLaskar
    @AnshumanLaskar 2 роки тому

    Ok i have a question isn't the name of an array a constant pointer, and if it is then how come the sizeof function doesn't return the size of the pointer and instead returns the size of the whole array?

  • @programmingwithme5701
    @programmingwithme5701 4 роки тому

    thankyou

  • @happydong8086
    @happydong8086 3 роки тому

    Thanks a lot :)

  • @-HarishkumarG
    @-HarishkumarG 3 роки тому +1

    Sir ! to find number of elements we should know the size of whole array ... And to find size of whole array we should have known number of elements .. so whyy ?🤷

    • @puneetkorjani6648
      @puneetkorjani6648 2 роки тому

      true tho i found same but it;s for computer easyness not our
      🤣🤣🤣🤣

  • @3h2pavankumarmanti46
    @3h2pavankumarmanti46 5 років тому +3

    Sir,can we use it to find number of characters,number of spaces and number of new lines in a paragraph?

  • @deathnote2481
    @deathnote2481 4 роки тому

    This is great..

  • @vipul-pawar
    @vipul-pawar 5 років тому

    very useful

  • @itsgamingtime..7001
    @itsgamingtime..7001 4 роки тому +1

    Cool!!

  • @true4189
    @true4189 4 роки тому

    Thank u

  • @technicalpradhan2936
    @technicalpradhan2936 5 років тому +1

    Achha tha lge rho

  • @Jeinilpatel-b4m
    @Jeinilpatel-b4m Рік тому

    what if we use for loop for this

  • @arnavraj4293
    @arnavraj4293 4 роки тому

    I used strlen instead of that you told, but from that method its only showing 1 as output, but there are 34 elements in there.

  • @KrishnaPatel-pv5nq
    @KrishnaPatel-pv5nq 9 місяців тому

    what if there are elements of different datatypes ??

  • @someone9189
    @someone9189 Рік тому

    What if you have some void indexes and now you want to count the elements in the array?
    Pls answer bro.

    • @__harsh_0001
      @__harsh_0001 4 дні тому

      Well what do you mean by void indexes

  • @venkateswarreddyannapuredd4114
    @venkateswarreddyannapuredd4114 2 роки тому

    What happens when we declare an array like this int arr[ ]={0};

  • @SOUNDRYAA-xs7hu
    @SOUNDRYAA-xs7hu 9 місяців тому

    Actually my reaction also matches with the dog's reaction !! ha ha

  • @veera_royal1573
    @veera_royal1573 3 роки тому

    But if there are 153 elements and we assume size of integer as 4bytes then the number elements will come in float value

    • @puneetkorjani6648
      @puneetkorjani6648 2 роки тому +1

      because when there is divsion of two int value ans in alwasys in int value

    • @Maha_s1999
      @Maha_s1999 2 роки тому

      @@puneetkorjani6648 sorry but that isn't quite true. if you divide 3 by 2, you don't get an integer, for example.

    • @puneetkorjani6648
      @puneetkorjani6648 2 роки тому

      @@Maha_s1999 bro if both 3 and 2 are of int data type then answer will be in int which is 1

  • @GurpreetSinghkalyan
    @GurpreetSinghkalyan 5 років тому

    When use Name of array in functions then it give address of first element but here it give whole size of array and when use &.array name then it give size of one element but in printf or in functions it give whole array address please explain

    • @GurpreetSinghkalyan
      @GurpreetSinghkalyan 5 років тому

      When print arryname it give first element address when arryname+1 it give next element address and when use &array name+1 then it goes outside the 1d array elements

  • @hindi-english1664
    @hindi-english1664 3 роки тому

    Can we perform same task except of sizeof operator? Please sir do this without sizeof operator ,i am trying.

  • @thejareddy4380
    @thejareddy4380 5 років тому +1

    Sir plz
    Reply to me
    When network classes willl strt

  • @gauravbaviskar4778
    @gauravbaviskar4778 5 років тому

    sir as arrays name represent its base address then then why sizeof (array name) is not equal to 4 as address is always integer plz reply sir...!!!

  • @nailasadaoui204
    @nailasadaoui204 2 роки тому

    But the size of 12 is not equal to the size of 2 in terms of bytes! Isn't it??

  • @codinglearner7664
    @codinglearner7664 3 роки тому

    Why not proper work on another coustom function?

  • @skygazer2678
    @skygazer2678 3 роки тому

    For some reason I am getting size of my array always 100. Can somebody help me. I tried making an separate array of size 5. Than used sizeof() to get the size of that array. And still I am getting 100 as size

  • @كلمهربنا-غ2ج
    @كلمهربنا-غ2ج 4 роки тому

    من فضلك اعمل كل الفديوهات بهذه الطريقه حتى لو مش هنفهم اللغه كويس هنفهم من طريقه العرض المبسطه و شكرا لك

  • @satyateja9579
    @satyateja9579 5 років тому +2

    Sir plz remind me for computer networks

    • @itbase2
      @itbase2 5 років тому

      its started dear

  • @ajaygautam6034
    @ajaygautam6034 2 роки тому

    But, why will we use it

  • @mrali1258
    @mrali1258 Рік тому

    ❤❤❤

  • @shivanichandrabansi5967
    @shivanichandrabansi5967 5 років тому +2

    Sir, how to find out the no of elements without using sizeof operator?

  • @hinataaaaaaaa
    @hinataaaaaaaa 9 місяців тому

    Love uuuuuu

  • @muskaan1537
    @muskaan1537 4 роки тому

    Cool

  • @gireeshbhat4158
    @gireeshbhat4158 3 роки тому +2

    Not sizeof() operater you are the supreman

  • @naveenkorlepara
    @naveenkorlepara 3 роки тому +1

    at last we dont know about size of array then how can we get 152

    • @Hyy.Its_Mann
      @Hyy.Its_Mann Рік тому

      Same question

    • @Ahmad-rj6dc
      @Ahmad-rj6dc 11 місяців тому

      The compiler(computer) knows how many elements in an array. @@Hyy.Its_Mann

  • @AshishKhetwal
    @AshishKhetwal 21 день тому

    0:23😂😂😂😂

  • @DalandanReal
    @DalandanReal 10 місяців тому

    if im rich im gonna donate you money now

  • @ankitkumaryadav1682
    @ankitkumaryadav1682 4 роки тому

    incorrect use of (sizeof function)

  • @abdousaadi2715
    @abdousaadi2715 3 роки тому

    قديشك فاضي وطويل بال يا أستاذ قاعد تكتب 152 رقم

  • @ireallyloveyou5786
    @ireallyloveyou5786 5 років тому

    This is too hard I need to go back and take my time then I will return here

  • @HelloWorld40408
    @HelloWorld40408 Рік тому

    Thank You Sir

  • @mdalaminhossian6343
    @mdalaminhossian6343 Рік тому

    Thanks a lot sir, giving us a great content

  • @rawishidreesi9950
    @rawishidreesi9950 5 років тому

    very helpful

  • @pauljoel471
    @pauljoel471 10 місяців тому +2

    Thank you