Pointer Arithmetic (Subtraction)

  Рет қаралды 165,545

Neso Academy

Neso Academy

Күн бұрын

Пікірлер: 77
@mrmakra-eo1kx
@mrmakra-eo1kx 5 жыл бұрын
Your way of teaching is way more better than any other way i have seen
@raviprakashmishra2860
@raviprakashmishra2860 4 жыл бұрын
this is best content u will ever come across in entire INTERNET
@parimalkothari7607
@parimalkothari7607 3 жыл бұрын
@David Clayton will u both stop spamming msgs......u use flexipay to take the credit card details of the payer....nothing else stfu
@youmemeyou
@youmemeyou Жыл бұрын
Ök
@nomad690
@nomad690 2 ай бұрын
Øk
@arkadiptadas4148
@arkadiptadas4148 5 жыл бұрын
Thank you, sir, for providing such quality lectures... Really helped me out in the interviews
@somasekhardakala2630
@somasekhardakala2630 5 жыл бұрын
I'm learning so much from your videos...Thank you...
@arularasij3099
@arularasij3099 4 жыл бұрын
I have really learned a lot. I had easily understand the concepts with the help of your videos . Thank you so much sir
@adithyasaiendla2485
@adithyasaiendla2485 4 жыл бұрын
Now concepts r crystal clear
@rinto_rnr
@rinto_rnr Жыл бұрын
Thanks for the great lecture you really saved me before my final exams.
@tails_the_god
@tails_the_god 2 жыл бұрын
thank you sir i can always depend on neso academy for giving me the answers im looking for! :D ❤
@cristianrestrepolopez976
@cristianrestrepolopez976 4 жыл бұрын
really helpful!
@creatorsayanb
@creatorsayanb 4 жыл бұрын
5:36 there should be *eqality, not inequality. I think that's a simple mistake. Thanks again for changing their life of so many students.
@brycehazen
@brycehazen 5 жыл бұрын
@7:19 did you mean to say the first element of array b? Isn't it point to the 3rd element?
@BobChevy73
@BobChevy73 5 жыл бұрын
I Think he meant 4th element. Index 3 is the fourth element. Index 0 is the first.
@adityasagarr
@adityasagarr 5 жыл бұрын
same thing here..
@sunilkarpe1518
@sunilkarpe1518 4 жыл бұрын
Why we can't add two pointers which are assigned to array Like p+q...(why only p-q is allowed)
@MonikaSingh-ee6yv
@MonikaSingh-ee6yv 4 жыл бұрын
Sir , how do I improve competitive coding skills? Please make video on it. Thanks in advance
@MrCEO-jw1vm
@MrCEO-jw1vm 9 ай бұрын
thanks so much for this wonferful content!
@NMAJJINEERAJA
@NMAJJINEERAJA 4 жыл бұрын
Really awesome sir actually I have a doubt on my mind while watching the video then I posted in comments but after watching the remaining video I got the answer for my question Thank you very much sir
@andre8844
@andre8844 Жыл бұрын
While practicing, I noticed if you make maybe q point to an address beyond the array length, maybe a[10], you will be getting some weird values. If in your program you have another array, you may end up pointing to a value in that array. Help make sense of c. I don't wanna be in a c(sea) of problems
@nikhilanand984
@nikhilanand984 4 жыл бұрын
what do you mean by running the program online and offline??
@nikhilanand984
@nikhilanand984 4 жыл бұрын
sir what will be the output if we take initially the index 0 and then subtract from it any positive integer.
@kamyagupta4030
@kamyagupta4030 2 жыл бұрын
thank you ♥️
@NMAJJINEERAJA
@NMAJJINEERAJA 4 жыл бұрын
Here we are using array and simply adding or subtracting the integer value from the pointer but if we are not dealing with the arrays and they asked to add 3 to the integer pointer without providing base then is it print error. Or any garbage value 🤔
@manupareek8776
@manupareek8776 5 жыл бұрын
any ways great teaching!
@manupareek8776
@manupareek8776 5 жыл бұрын
sir. is the c language course completed? if not, then how much course is completed? i mean is it 80% or 70% complete?
@kavanajois9435
@kavanajois9435 3 жыл бұрын
you are genius
@true4189
@true4189 4 жыл бұрын
Thank u
@bishnupadamaity4198
@bishnupadamaity4198 4 жыл бұрын
What if we want to subtract 3 from a[0] ?
@oggy107
@oggy107 4 жыл бұрын
if we subtract something from base address of arr[0] then it simply means that the resulting adress will be out the range of that array and it will produce unexpected result.
@cuteonigiri1671
@cuteonigiri1671 Жыл бұрын
2 yrs late but ig a[0]-3 is the answer?
@cuteonigiri1671
@cuteonigiri1671 Жыл бұрын
int *p=&a[0]; *p-3 also can do
@yevgeni10
@yevgeni10 3 жыл бұрын
7:20 pointer q points to the first Array element ??
@marbles5590
@marbles5590 2 жыл бұрын
7:21 *must be fourth element in b[ ]
@kornmc
@kornmc 2 жыл бұрын
i think subtraction in array output is giving not a array element. outpu giving only integer ?
@rockstarmani
@rockstarmani 4 жыл бұрын
Can any one clarify me??? If we substract two pointers Belonging to Same array,we can access element of corresponding index! What happen if we add two pointers of a same array??? Is it garbage value??? p and q are pointing to same array! Int *p; Int *q; Printf("%d",*(p+q)); o/p???
@dipeshranadipeshrana881
@dipeshranadipeshrana881 2 жыл бұрын
It's illegal in c. Try yourself by writing program
@abhishekkumarsingh755
@abhishekkumarsingh755 2 жыл бұрын
Sir, if *p = &a[0] and *q = &a[3] and if we subtract q - p we still get &a[3], but in array should'nt we take one step backward from 3 and get &a[2}. ?
@dipeshranadipeshrana881
@dipeshranadipeshrana881 2 жыл бұрын
No search in Google. Subtracting pointer gives distance between element of array. So like a+2 points to third element . subtracting address of first element and third element will give 2 hence printing a[q-p] prints third element
@MysticRogue_09
@MysticRogue_09 2 жыл бұрын
At 4:18 what happens if we do p-q will it give error ?
@anubhabpanda6503
@anubhabpanda6503 2 жыл бұрын
-7 o/p
@janaey158
@janaey158 3 жыл бұрын
So is p=p-3 not a legal argument? I have to multiply to achieve the correct result?
@sunilkarpe1518
@sunilkarpe1518 4 жыл бұрын
Why we can't add two pointers which are assigned to array Like p+q...(why only p-q is allowed)
@cuteonigiri1671
@cuteonigiri1671 Жыл бұрын
supposedly q=&a[0], where p contain address of a (assume 1000 as a[0] address) p=&a[1], address = 1004 since 1 element contain 4 byte. if u do p-q, u will get the element in the array. p-q = (1004-1000)\4 = 1. so a[p-q]=a[1]. if u do p+q=(1004+1000)\4 = 501 a[p+q] = a[501]. unless u have the element in a[501], it might give u garbage value
@cuteonigiri1671
@cuteonigiri1671 Жыл бұрын
please correct me if im wrong. cuz thts how i understand it
@devsutong
@devsutong 4 жыл бұрын
do we actually have to do this?? i didnt divide by 4 but it still works!?
@indiancoder8301
@indiancoder8301 5 жыл бұрын
How much % of the course is completed
@subasris7151
@subasris7151 4 жыл бұрын
what happens when two pointers are added ?
@harcharansingh1997
@harcharansingh1997 4 жыл бұрын
At last question how output offline comes -1 plzzz anyone explain it
@yoddha621
@yoddha621 4 жыл бұрын
Its not about online and offline you will always get different value when you add or subtract two pointers pointing to two different arrays.
@qandos-nour
@qandos-nour 4 жыл бұрын
why the distance between pointers is 4 not 3??
@devsutong
@devsutong 4 жыл бұрын
because integers are hardcoded in c language to take 4byte of memory space in the memory
@kshitizshrestha9398
@kshitizshrestha9398 3 жыл бұрын
@@devsutong Not actually, It depends on the architecture of the computer that how much memory does an integer or any other data type take. Back in the days, a 16-bit architecture used to take an int as 2 bytes.
@devsutong
@devsutong 3 жыл бұрын
@@kshitizshrestha9398 youre right its architecture specific
@utkarshsingh8251
@utkarshsingh8251 4 жыл бұрын
can i subtract 3 from 0
@vikashmishra1903
@vikashmishra1903 4 жыл бұрын
Yup It will give uh garbage value(not error)
@quantumnature6641
@quantumnature6641 4 жыл бұрын
Wwwoooooowwwww..... 0 dislikes and 234 Likes... I have see. First time in you tube channel... I am socked.... 🤗🤗🤗🤗🤗🤗🤗🤗🤗🤗🤗
@santhosh6784
@santhosh6784 5 жыл бұрын
What will happen if p points to the first element of an array and we are going to subtract an integer from it, like this int a[ ] = { 1,2,3,4 }; int *p = a; printf("%d", *(p - 1));
@raviranjanjha3677
@raviranjanjha3677 4 жыл бұрын
Garbage value
@chintumohan6110
@chintumohan6110 3 жыл бұрын
@@raviranjanjha3677 why we did not use * in print statement for both p and q it producing error without *
@gowthams4360
@gowthams4360 2 жыл бұрын
I think it produce error the pointer is staying at starting position.it can't go back it's illegal
@anuragupadhayay4505
@anuragupadhayay4505 4 жыл бұрын
p = &a[0]; p = p - 1; //This'll be an error right?
@cuteonigiri1671
@cuteonigiri1671 Жыл бұрын
it wont gives u error but the result of the address number of a[0] being subtracted by 1. for example, my result = 6475263 like tht.
@abhishekbiswas2267
@abhishekbiswas2267 3 жыл бұрын
I did *ptr = & a[0] and then ptr = ptr-3; suddenly I see blue screen "your system ran into an error" 😭😭🤣😁
@shaikhsaberaalam1019
@shaikhsaberaalam1019 4 жыл бұрын
can't the base pointer be 996 instead of 1000?
@vikashmishra1903
@vikashmishra1903 4 жыл бұрын
He is just assuming the base as 1000 so it can make calculation easier that's it...if uh bad in maths and beginner in programming than take base as 437 (random) than perform operation uh will get confuse.
@shaikhsaberaalam1019
@shaikhsaberaalam1019 4 жыл бұрын
@@vikashmishra1903 thank you
@vikashmishra1903
@vikashmishra1903 4 жыл бұрын
@@shaikhsaberaalam1019 come come welcome 🤗
@hetaeramancer
@hetaeramancer 3 жыл бұрын
@@vikashmishra1903 what the fuck is come come welcome?
@hellocreep8986
@hellocreep8986 3 жыл бұрын
@@hetaeramancer tu kha se
@mehedihassan4653
@mehedihassan4653 4 жыл бұрын
😣😵😵
@durnibar3886
@durnibar3886 2 жыл бұрын
#include int main() { int a[] = {1, 2, 3, 4, 6, 4}; int *ptr = &a[2], *q = &a[5]; printf("%d %d ", ptr, q); printf("%d", q - ptr); return 0; } it should have given output 12, but why the hell is it giving output 3
@cuteonigiri1671
@cuteonigiri1671 Жыл бұрын
because u r subtracting the the address instead of the element. u should use *q - *ptr instead
@cuteonigiri1671
@cuteonigiri1671 Жыл бұрын
#include int main() { int a[]={5,47,65,43,10}; int *p,*q; p= &a[3]; q= &a[0]; int sub=a[p-q]; printf("%d", sub); } i did it like this to print the element after subtracting between the pointer tho i dont the use of subtracting them...
@hardikpatel352
@hardikpatel352 Жыл бұрын
can anyone please give the solution of this #include char *c[] = {"GeksQuiz", "MCQ", "TEST", "QUIZ"}; char **cp[] = {c+3, c+2, c+1, c}; char ***cpp = cp; int main() { printf("%s ", **++cpp); printf("%s ", *--*++cpp+3); printf("%s ", *cpp[-2]+3); printf("%s ", cpp[-1][-1]+1); return 0; }
@true4189
@true4189 4 жыл бұрын
Thank u
Pointer Arithmetic (Increment & Decrement)
4:07
Neso Academy
Рет қаралды 179 М.
Pointer Arithmetic (Addition)
7:10
Neso Academy
Рет қаралды 254 М.
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
Using Array Name as a Pointer
6:54
Neso Academy
Рет қаралды 174 М.
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 584 М.
Pointers (Important Questions)
11:11
Neso Academy
Рет қаралды 364 М.
you will never ask about pointers again after watching this video
8:03
Programming with Math | The Lambda Calculus
21:48
Eyesomorphic
Рет қаралды 261 М.
Advanced C: The UB and optimizations that trick good programmers.
1:12:34
Eskil Steenberg
Рет қаралды 198 М.
why do void* pointers even exist?
8:17
Low Level
Рет қаралды 408 М.
Pointer Pointing to an Entire Array
5:22
Neso Academy
Рет қаралды 224 М.
The 7 Levels of Math Symbols
14:03
The Unqualified Tutor
Рет қаралды 67 М.
Une nouvelle voiture pour Noël 🥹
00:28
Nicocapone
Рет қаралды 9 МЛН