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❤❤❤❤
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]))
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.
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.
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
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 😕 ........
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; }
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?
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 ?🤷
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
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
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
You are a real gem. We need more teachers like you.
Thank you.
u r great man who can attract most of the students by your words
You just wrote 152 elements only to show us how the sizeof operator works!
Really admirable ❤
Happy teacher day sir
Thanku to make learning C so simple
no no sir we are not angry with you...we just love you ..the best teacher
Amazing video Sir, very easy to understand not only this, but whole playlist...Thank you.
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❤❤❤❤
very understanding video.thank you!
I love Neso Academy 💝.
straight to the point !! nice one!!
Thank you so much! I was really struggling to understand summing arrays coming from python to c++, but you cleared it up perfectly!
Tussi great ho brother! 🙏🙌🏻
Clear explained all videoes
Super bro I understand clearly thank you bro
U r too good sir!!!
You guys are the beast
thumbs up for simple and easy explanation
this guy is a genius
W........o.........w .........just wow 👏 what a explanation 🤩!!
Awesome video
Thanks again
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]))
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.
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.
this is fun to study wow
that is veary helpfull thanks
really good lecture ..
thank youu😭😭😭😭😭
thank you
Thanking you sir
Excellent
Thank you!!!
Good
Thanks a lot sir...giving us a great content
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
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 😕 ........
Still 10
size of int 2 bytes
U're awesome! thank you very much
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;
}
cool trick, thanks
THANKS, A LOT SIR
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?
thankyou
Thanks a lot :)
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 ?🤷
true tho i found same but it;s for computer easyness not our
🤣🤣🤣🤣
Sir,can we use it to find number of characters,number of spaces and number of new lines in a paragraph?
Yes u can
This is great..
very useful
Cool!!
Thank u
Achha tha lge rho
what if we use for loop for this
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.
Strlen is for strings.
@@amantyagi6057 average = (sum)/(length or count of elements)
what if there are elements of different datatypes ??
What if you have some void indexes and now you want to count the elements in the array?
Pls answer bro.
Well what do you mean by void indexes
What happens when we declare an array like this int arr[ ]={0};
Actually my reaction also matches with the dog's reaction !! ha ha
But if there are 153 elements and we assume size of integer as 4bytes then the number elements will come in float value
because when there is divsion of two int value ans in alwasys in int value
@@puneetkorjani6648 sorry but that isn't quite true. if you divide 3 by 2, you don't get an integer, for example.
@@Maha_s1999 bro if both 3 and 2 are of int data type then answer will be in int which is 1
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
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
Can we perform same task except of sizeof operator? Please sir do this without sizeof operator ,i am trying.
Sir plz
Reply to me
When network classes willl strt
Wait some day's after
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...!!!
Integer size 4 byte
But the size of 12 is not equal to the size of 2 in terms of bytes! Isn't it??
Why not proper work on another coustom function?
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
من فضلك اعمل كل الفديوهات بهذه الطريقه حتى لو مش هنفهم اللغه كويس هنفهم من طريقه العرض المبسطه و شكرا لك
Sir plz remind me for computer networks
its started dear
But, why will we use it
❤❤❤
Sir, how to find out the no of elements without using sizeof operator?
Using largest designator in the list
Using for loop
just spend some time on counting them
Love uuuuuu
Cool
Not sizeof() operater you are the supreman
at last we dont know about size of array then how can we get 152
Same question
The compiler(computer) knows how many elements in an array. @@Hyy.Its_Mann
0:23😂😂😂😂
if im rich im gonna donate you money now
incorrect use of (sizeof function)
Explain it then wats the incorrect?
قديشك فاضي وطويل بال يا أستاذ قاعد تكتب 152 رقم
This is too hard I need to go back and take my time then I will return here
Thank You Sir
Thanks a lot sir, giving us a great content
very helpful
Thank you