Pointer Arithmetic (Addition)

  Рет қаралды 241,670

Neso Academy

Neso Academy

Күн бұрын

Пікірлер: 354
@iamaprogrammer1022
@iamaprogrammer1022 5 жыл бұрын
Initially p has address of a[2]... And p=p+2 means two shift towards right from initial address.. So now.. P will have a[4].
@mdghufranalam7369
@mdghufranalam7369 2 жыл бұрын
and uh also write as P will have 4[a].
@modapothularajasekhar4645
@modapothularajasekhar4645 2 жыл бұрын
[4]
@youmemeyou
@youmemeyou Жыл бұрын
​@@modapothularajasekhar4645&[øk]
@TantawyAhmad
@TantawyAhmad 5 жыл бұрын
WOW!! Literally, best programming intro and C explanation I've seen so far the series is Amazing!! ❤ and the explanation is very simple😊 Please post daily content👌 I came here for the "Data Structure intro" but found the explanation worth to review the basics of programming all over again. I'm sure the other playlists are as good as this one. Thank you so much!!😊 Please post from the Data Structure part on your road map 🙏 >>Data Structures: 1) Stacks 2) Queues 3) Linked list 4) Trees 5) Binary search trees 6) Binary heaps 7) Graphs 8) Tree traversals
@tlarson91119
@tlarson91119 3 жыл бұрын
0:50 A shorter way would be to just get rid of the ampersand and [0]. When an array name is used in an expression, the array is automatically cast to a pointer to the first element of the array. So one could also write: int *p = a;
@simonmarabi2661
@simonmarabi2661 3 жыл бұрын
exactly
@hetaeramancer
@hetaeramancer 3 жыл бұрын
he's teaching it systematically. mentioning that shortcut will cause confusion to beginners
@techmad8204
@techmad8204 3 жыл бұрын
Yes, isn't this the reason why we don't use & in scanf for strings?
@gyanusingh9416
@gyanusingh9416 2 жыл бұрын
@@techmad8204 yeah man
@sahil1307
@sahil1307 2 жыл бұрын
@@techmad8204can you tell me which resources are you using to learn c
@abdelrahmanm.6215
@abdelrahmanm.6215 4 жыл бұрын
Your videos have honestly made a HUGE difference in my academic career. i thank you from the bottom of my heart for putting in the effort and time.
@MrAjaypatole
@MrAjaypatole 3 жыл бұрын
Base Address= 1000 , p= &a[2] = 1008 , p= p+2 = 1008+2*4 = 1016 , p= a[4]
@swapnilchavan8378
@swapnilchavan8378 2 жыл бұрын
Awesome
@andreeastanciu328
@andreeastanciu328 5 жыл бұрын
This is the most amazing C tutorial. ❤️ Very good job, I can't wait for the playlist to be finished.
@seunlivefootball
@seunlivefootball 4 жыл бұрын
Wish i could see you and give you a hug, like right now! I have been trying to understand this pointer of a thing for more that three days, but here comes NESO ACADEMY which such a lucid explanation. Thank you very much! You've made my day.
@labandaetoilista4873
@labandaetoilista4873 4 жыл бұрын
The answer is : the pointer will point to : a[4]
@bhargavskulkarni2855
@bhargavskulkarni2855 Жыл бұрын
How
@bbom9197
@bbom9197 Жыл бұрын
​@@bhargavskulkarni2855it moves the pointer 2 index forward. Thats the fifth index Which we write a[4] Because counting begins from 0
@pascalchinedu6705
@pascalchinedu6705 2 жыл бұрын
This series has made me attempt C programs I found difficult. I can't thank you enough sir. Better late than never. I'm glad I saw this academy
@080_cse_sanjaykarthicks4
@080_cse_sanjaykarthicks4 3 жыл бұрын
Initially I thought that the pointer concept is very complex. But after watching videos of NESO academy about the pointers,I have started to understand the concept. Thanks for the instructor for making me understand the complex concept in an efficient way.
@sunilkumarreddy6537
@sunilkumarreddy6537 5 жыл бұрын
It is realy a good explination for me apart from the class and coaching section. Thank you sir
@Neha-zm7by
@Neha-zm7by 2 жыл бұрын
I never commented on anyone youtube channel but neso how can i thank you i am understanding everything(apart from recursion) and now i think i can pass my exam
@nisha..sharma..8554
@nisha..sharma..8554 3 жыл бұрын
I have taken course on udemy in c programming.. but after some days I have seen this channel on KZbin .. and I have a thought about wasting my money on udemy... ❤️❤️❤️... Thank u so much sir..
@nirbhayparmar
@nirbhayparmar 4 жыл бұрын
a[4], 5th element of the array
@shiranabbasi3044
@shiranabbasi3044 Жыл бұрын
No need to multiply by 4 in case of int array. See this example int size = 4; int arr[] = {1, 2, 3, 4}; int* p = &arr; *(p + 1) = 9; for (int i = 0; i < size; i++) { printf("%d ", arr[i]); } It should print: 1 9 3 4
@ramarajujaya2480
@ramarajujaya2480 3 жыл бұрын
i can't express my happiness to find a great lecturer like u i am veryveryvery very happpy
@OshiniVidharaJayaweera
@OshiniVidharaJayaweera 3 ай бұрын
Thank you so much for these amazing videos. I understood really well what are pointers and literally I understand each point you explain. The best teacher ever for programming. Whoever I meet with doubts in C I will recommend Neso academy for sure
@raghavattri9449
@raghavattri9449 3 жыл бұрын
I tried various platforms to learn c but the quality of explanation that u give is next level
@studyspectra_1980
@studyspectra_1980 3 жыл бұрын
And is a[4]..as p=p+2 simply means shifting the pointer by 2 units from the initial position in forward direction..ie.from a[2] to a[4]..
@yasharora4300
@yasharora4300 4 жыл бұрын
Thank you so much sir. Best explanation on complete KZbin.
@badavathjaipal7027
@badavathjaipal7027 2 жыл бұрын
primary address is p is array of 3rd element i.e p=&a[2],when we add p=p+2 then new address i.e p=&a[2+2]=&a[4].which refer 5th element.
@rajivkumawat7940
@rajivkumawat7940 2 жыл бұрын
ans is 4. sir i am 1st year student in iiit gwalior in IT stream. my programming language was going extremly wrost but neso academy saved my engineering life .i saw many youtube channel related to programming language but this one is extremly good. i gain more dept interest in programming because of you. so thank you very much sir for creating such kind of channel which helps all students . 🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏thank you very much sir 🙏🙏🙏🙏🙏🙏
@ashwanikumarsrivastava1187
@ashwanikumarsrivastava1187 4 жыл бұрын
You are the best teacher for C programming
@niteshsoni8956
@niteshsoni8956 3 жыл бұрын
ANS- index will be 4....Sir thank you so much for teaching and sharing such amazing knowledge of C with us!!
@seshanky
@seshanky 9 ай бұрын
Brother am sry but can u pls say what is an index 😅
@EigenA
@EigenA 3 жыл бұрын
Taking care of me in signals, controls, and now during an internship. Great work!
@tinkukumarsiddharth2281
@tinkukumarsiddharth2281 3 жыл бұрын
I didn't understand the any programming language in the,but here I am learning it with the interest.
@mohamedmezid4821
@mohamedmezid4821 Жыл бұрын
Answer of the question: After the operation "p = p + 2", the pointer p will now point to the memory address that is 2 elements ahead of its current location. Since the initial value of p is the address of the 3rd element of the array i.e &a[2], after the operation p = p + 2, the pointer p will point to the 5th element of the array i.e p = &a[4]. Therefore, the index of the array after this operation is 4.
@adnaneafifi4734
@adnaneafifi4734 3 жыл бұрын
If we want a[2+2] a[4] we have to multiply p=p+2*4 if we assume that the data stored is an integer.... and if we assume that the value of the integer a[2] is in 1002 to go to a[4] we have to add 4 and add 4 again 2*4
@asmiachiproduction
@asmiachiproduction 2 жыл бұрын
If only if this video exists back in 2017, I would have excelled my programming paper. Thanks for the great content.
@abbikgg3992
@abbikgg3992 Жыл бұрын
@jw72jswu728uwj You don't know his circumstances. Maybe he dropped and coming back at it again. Mind your own business.
@preetimadas3517
@preetimadas3517 3 жыл бұрын
It will be a[4].... And sir you are amazing..... I m literally getting to understand C learning from u....
@priyankarodda1943
@priyankarodda1943 4 жыл бұрын
Excellent Teaching I get clear about pointers 👏👏👏👏👏👏👏
@sudipsen3677
@sudipsen3677 4 жыл бұрын
Nice explanation sir ❤️ really amazing .Thank You
@creatorsayanb
@creatorsayanb 3 жыл бұрын
I'm looking that so many comments are a[4]. But p=&a[2] which means the base value of a[2]. When we write p=p+2, then base value will added with 2. and the output of p will be a base value only. Not a value like a[3],a[4] etc.
@samrudhshetty9334
@samrudhshetty9334 6 ай бұрын
your totally correct bro. my brain was rotting reading the comment sectiom
@ajmalkhaniit
@ajmalkhaniit 4 жыл бұрын
Index will be 5 bz pointer contains third address of array and we 2 in this so pointer will move 2 position in forward direction
@EyeNeo
@EyeNeo 3 жыл бұрын
Index will be the p[4] which is actually the fifth element of the array.
@TEeducation
@TEeducation 4 жыл бұрын
'P' will point the &a[4] of the array, that means i will point he 5th element of thee array.
@emperorisalive
@emperorisalive 6 ай бұрын
The video explains pointer arithmetic, specifically how adding an integer to a pointer moves the pointer forward by that many positions in the array. It provides examples and explains the underlying memory layout. Key moments: 00:00 Understanding pointer arithmetic is crucial in programming. Adding an integer to a pointer moves it to the next memory location, not just by the integer value, due to memory allocation. -Pointer arithmetic involves moving pointers to different memory locations based on integer additions. -Explaining the concept of adding an integer to a pointer using a practical example with array indexing. -Detailing the memory allocation and the impact of adding an integer to a pointer on memory addresses.
@080_cse_sanjaykarthicks4
@080_cse_sanjaykarthicks4 3 жыл бұрын
The answer to the h.w qn is 4 as first the pointer pointed to the index 2 and p=p+2 moves 2 positions to the right, and so now the pointer will point to index 4,i.e,p=&a[4]
@nawalazhar
@nawalazhar 4 жыл бұрын
please add more topics! i love your explanation style!!
@otetumooluwaseun3948
@otetumooluwaseun3948 4 ай бұрын
As p contains the address location of a[2] p + 2 will be a[4] ie the fourth index of a
@ankitaverma2271
@ankitaverma2271 5 жыл бұрын
So the index of the array after this operation is p=a[4]. Sir please let us know whether it js the right answer or not?
@QuotationNation
@QuotationNation 3 жыл бұрын
right
@Tanzimhossain2
@Tanzimhossain2 Жыл бұрын
6:38 a[2+2]= a[4]
@wastetanz
@wastetanz 3 жыл бұрын
this was so clear! thank you for this
@adityathakur8951
@adityathakur8951 Жыл бұрын
Abee
@tamimurrahman619
@tamimurrahman619 3 жыл бұрын
p=&a[2]------->address of array 1008--------->elements position is 3rd in array; =>p=p+2=p+2*4=1008+8=1016; -------->which location is address of array a[4](1016)---->elements position is 5th in array.....
@raktimmandal2476
@raktimmandal2476 4 жыл бұрын
Initially p has address of a[2]. And "p=p+2" means two shift forward from initial address. So now - P will have a[4]. because 2+2=4.
@achugh52
@achugh52 Ай бұрын
pointer p will have address of p[4] hence point to p[4].
@himanshuranjan657
@himanshuranjan657 4 жыл бұрын
The explanation is like butter
@AshishKumar-rb1gw
@AshishKumar-rb1gw 2 жыл бұрын
Programming language is very good and practice with me and improve skills thinku you so much your practice white
@SarthSanjayJoshiBEE
@SarthSanjayJoshiBEE Жыл бұрын
The index of the array pointed by the pointer p will be a[4]
@shreyasingh222
@shreyasingh222 3 жыл бұрын
Thanks for such great explanation ....
@twiz8859
@twiz8859 2 жыл бұрын
Century complete now second century on. Can we say 6:00 p+3*4=Base address+next Element*total byte of that element.
@shaireenwaheed6492
@shaireenwaheed6492 3 жыл бұрын
Sir ans is Base add a[0]+2*4 And Index 2
@RAVIVERMA-zy3vs
@RAVIVERMA-zy3vs 4 жыл бұрын
Lets consider the base address is 1000 and currently the pointer is at 3rd element which means 1000+4+4=1008 is equal to & a[2] and we have to add 2 to it p=p+2 means 1008+2*4=1016 Which is nothing but & a[4] so this is the Answer...
@vaibhavsharma9298
@vaibhavsharma9298 2 жыл бұрын
Amazing video 🙆‍♂️
@shivamrawat4289
@shivamrawat4289 4 жыл бұрын
HOMEWORK QUESTION we will get index 4 i.e.a[4] --(EXPLANATION)------->>>>>suppose we take &a[2]=1000, so according to question (p) is equal to 1000 and if we perform p=p+2*4 as earlier explained in the current video , we will get p=1008 and each element of array ocupy 4 bytes of memory , so definetly after reaching from address 1000 to 1008 we have moved two index value forward means from a[2] to a[4], means from index 2 to index 4. So final ans is we have reached a[4]. hope you all understand :) .
@devsutong
@devsutong 4 жыл бұрын
why did the instructor says that we should multiply by 2 by 4 in 5:40
@shivamrawat4289
@shivamrawat4289 4 жыл бұрын
@@devsutong bro simply we can say it is the formula to perform such things and practically if we do this question on compiler same output we get so we can say that we have understood which formula compiler use to perform such functions .
@devsutong
@devsutong 4 жыл бұрын
@@shivamrawat4289 ok now i understand, good explanation by the instructor but his English is very misleading
@nizammalik2148
@nizammalik2148 3 жыл бұрын
Amazing explanation.
@Perceptionz_Sound
@Perceptionz_Sound 2 жыл бұрын
Great video.
@D-Coder440
@D-Coder440 Жыл бұрын
Thank You Soo Much
@ashishkumarpal380
@ashishkumarpal380 5 жыл бұрын
Initially p have &a [2] and after p=p+2 address will be shift two index right so ans is &a [4]
@tejparmar3440
@tejparmar3440 5 жыл бұрын
Initial index value of p=2 and after adding 2 it will become p=4
@venkateshpulukuri4832
@venkateshpulukuri4832 3 жыл бұрын
in writing of address ,p=p+1*size of the data type ;is better i thought
@jakemichaelwilson
@jakemichaelwilson 2 жыл бұрын
Thanks again for the videos. At 5:05 I'm confused why the video shows p=p+1 when the correct way is p=1000+1x4? Is the prior the way how it should be written in C? I already watched the following video as well. It would clear things up if I understood why it is important to understand both math concepts? Which one is the code format for C?
@clashbegins2063
@clashbegins2063 2 жыл бұрын
its only p+1 not p+1*data type
@maxcanten2922
@maxcanten2922 Жыл бұрын
P points to the array a[4] And index will be 5
@tayyab.sheikh
@tayyab.sheikh 10 ай бұрын
H.W problem : p = &a[2] ; p = &a[2] + 2 ; ❌ p = &a[2 + 2] = &a[4] ; ✔️
@mokkalapradeep7290
@mokkalapradeep7290 5 жыл бұрын
please make a videos in sorting techniques and some more programs on patterns it is important they test us logical knowledge
@MuhammadAbdullah-wx1ev
@MuhammadAbdullah-wx1ev Жыл бұрын
here a[2] means third element so p+2 wil shift the pointer to the fifth element so the final answer will be p=&a[[4]
@engineer7857
@engineer7857 3 жыл бұрын
Thank you for this wonderful job. 😀
@nehajaiswal3942
@nehajaiswal3942 4 жыл бұрын
Best explanation ever
@48_subhambanerjee22
@48_subhambanerjee22 2 жыл бұрын
answer to homework question: it will point to a[4].. that means, 5th element in the array
@HopeNHopes
@HopeNHopes 18 сағат бұрын
The answer is a[4] that is the fifth element of the array;//
@KumarRavi_25
@KumarRavi_25 3 жыл бұрын
You are Doing a great work❤️❤️
@manavbabber5454
@manavbabber5454 4 жыл бұрын
Please upload the videos of data structure topics including stacks,queues,heaps,linked lists etc
@HinaFirdaus
@HinaFirdaus 5 жыл бұрын
4th index or 5th element 4B base address then 1016
@techys4335
@techys4335 3 жыл бұрын
pointer will point index 4 i,e 5th element of an array
@nuralyazafira1960
@nuralyazafira1960 3 жыл бұрын
answer p will point to the fourth elements so p=&a[4]
@aatmprakash
@aatmprakash 4 жыл бұрын
please make video on MICROPROCCESSOR 👍👍👍
@anandharsh1773
@anandharsh1773 3 жыл бұрын
thanku sir ur great .........
@TheRedTeam
@TheRedTeam 5 жыл бұрын
Fried my brain. Good night.
@jeedikantivenkat7814
@jeedikantivenkat7814 5 жыл бұрын
Index of array will be 5 Pointer will point to a[4]
@andiespeg1897
@andiespeg1897 3 жыл бұрын
Is element and index the same... If not... It will point to element 5... Index 4...
@CheapPhysics
@CheapPhysics 2 жыл бұрын
The index is 4.. And the memory location is 1016.... (Say 0 index has 1000 memory location)
@priyaupwanshi8063
@priyaupwanshi8063 3 жыл бұрын
Index = a[4] after p = p + 2
@zainabbohra2915
@zainabbohra2915 3 жыл бұрын
Amazing sir😎
@true4189
@true4189 4 жыл бұрын
Thank u
@castiel0504
@castiel0504 3 жыл бұрын
I think the answer is p=[a4]...Because pointer shifts 2 places in the right direction.
@akhil9967
@akhil9967 3 жыл бұрын
If initial address is 1000 then 1016 is the location that pointer points to.
@mouneshdb9211
@mouneshdb9211 3 жыл бұрын
a[4] or 5th element of array
@rashmisharma9397
@rashmisharma9397 4 жыл бұрын
P=p+2 as you earlier said that we have to multiple the memory byte the int is taking so why we are not multiplying 4 to 2
@java_shaileshkushwaha878
@java_shaileshkushwaha878 4 жыл бұрын
Because p=p+2 is also equivalent to p=p+2*4 but here i do explicitly but compiler do implicit Internally compiler do same as your thought but we not use this type calculation it is time consume working same
@pranavhendre6209
@pranavhendre6209 Жыл бұрын
the answer :-a[4];
@negativedignity8994
@negativedignity8994 3 жыл бұрын
saying p = &a[2] and after the operation p = p + 2 the answer will be p = &a[2 + 2] === p = &a[4]
@kunaii_cs
@kunaii_cs 4 жыл бұрын
Its the fifth elemnt or p=&a[4]
@myviews8991
@myviews8991 4 жыл бұрын
Index of the array remains same as we are incrementing the address in the pointer by 2 but index of the array was never changed......
@DeepakKumar-fd4qu
@DeepakKumar-fd4qu 5 жыл бұрын
Sir please make a video on structure and union as soon as possible please huge request to you
@sr-sunny-raj
@sr-sunny-raj 4 жыл бұрын
index after operation will be -: 4.
@compangit1524
@compangit1524 Жыл бұрын
The index will be at the 5th elements of the array.
@raghavan8594
@raghavan8594 4 жыл бұрын
Sir,what if, initially when 'p' points to final element??
@akshitarora470
@akshitarora470 4 жыл бұрын
You will be able to view the address next in line (4 bytes separated) , but obviously doing a *p for that memory location will result in an error.
@sandraokafor5380
@sandraokafor5380 3 жыл бұрын
The answer is a[4]. I love these videos a lot, they are quite explanatory. Thank you.
@amrnassar8417
@amrnassar8417 5 жыл бұрын
thank you
@kunjd26
@kunjd26 2 жыл бұрын
Answer is: a[4]
@GurpreetSinghkalyan
@GurpreetSinghkalyan 5 жыл бұрын
Excellent
Pointer Arithmetic (Subtraction)
7:59
Neso Academy
Рет қаралды 157 М.
Pointers (Important Questions)
11:11
Neso Academy
Рет қаралды 347 М.
小丑家的感情危机!#小丑#天使#家庭
00:15
家庭搞笑日记
Рет қаралды 38 МЛН
Try Not To Laugh 😅 the Best of BoxtoxTv 👌
00:18
boxtoxtv
Рет қаралды 4,6 МЛН
Сюрприз для Златы на день рождения
00:10
Victoria Portfolio
Рет қаралды 2,7 МЛН
Pointer Arithmetic - *p++;  *++p; ++*p;
10:25
Abdul Bari
Рет қаралды 189 М.
you will never ask about pointers again after watching this video
8:03
Structure Padding in C
8:42
Neso Academy
Рет қаралды 244 М.
Call By Value & Call By Reference in C
8:34
Neso Academy
Рет қаралды 1,3 МЛН
C_77 Pointers in C- part 7 | Pointer Arithmetic (Increment/Decrement) program
21:03
why do void* pointers even exist?
8:17
Low Level
Рет қаралды 379 М.
C pointers explained👉
8:04
Bro Code
Рет қаралды 182 М.
小丑家的感情危机!#小丑#天使#家庭
00:15
家庭搞笑日记
Рет қаралды 38 МЛН