In the statement printf("%d %d %d ", (*p)++, *p++, *++p);, it might seem that the operations should be evaluated from right to left due to operator precedence or associativity, but that's not how function argument evaluation works in C. Understanding the Concept: Operator Associativity vs. Function Argument Evaluation: Operator Associativity refers to how operators of the same precedence are grouped in the absence of parentheses (e.g., a + b + c is left-to-right because + is left-associative). However, function arguments in C are not evaluated based on the associativity of the operators within the arguments. Instead, the order of evaluation of function arguments is unspecified in the C standard. Unspecified Evaluation Order in C: The C standard does not define the exact order in which function arguments are evaluated (i.e., whether arguments are evaluated left-to-right, right-to-left, or in any particular order). This means that depending on the compiler, the order can vary. Most modern compilers tend to evaluate arguments from right to left, but it’s not guaranteed, and the standard doesn’t mandate it. Side Effects with Increment Operators: In this case, the post-increment and pre-increment operators (++) introduce side effects, which change the value of p (the pointer) during argument evaluation. This makes it tricky to predict the exact output without knowing how the compiler evaluates the function arguments. Example Breakdown: Let’s analyze what happens in the statement printf("%d %d %d ", (*p)++, *p++, *++p);. (*p)++: This returns the value that p points to (dereferenced), then increments the value at p. *p++: This returns the current value at p, then increments the pointer p to point to the next location. *++p: This first increments the pointer p, then returns the value at the new location. Now, based on how the compiler decides to evaluate the arguments, the exact order of pointer increments and dereferencing will differ. Why Associativity Doesn’t Apply: Operator associativity applies when you have multiple operators of the same precedence in a single expression (like a + b + c). Function argument evaluation is not governed by associativity rules but by the fact that the C standard leaves the order of evaluation unspecified. Therefore, associativity doesn't determine how arguments like (*p)++, *p++, and *++p are evaluated. Conclusion: The evaluation order of the arguments in printf is unspecified, meaning the compiler can choose the order in which these arguments are processed. This is why associativity (whether right-to-left or left-to-right) does not govern the behaviour here. The key takeaway is to avoid relying on the evaluation order when using side-effect-producing expressions like ++ in function arguments, as the result may vary across compilers.
I think that pointer topic is so tough...but when I saw your lecture it so simple ..for me ,thank you mam...really that you given problem are make practice
Thank you mam for a wonderful explanation . Mam I have one that is we are going to get the output of star p as zero in that case why the value got changed in place of -1 to 0 . In the first code problem.
thanks mam for helping us specially in present era..it is a very famous maxim that people help u ,u r lucky if people don't help u its very common.i have seen 1st 20 video in a day ..all are quite interesting and understandable. I have learnt more.thsnks
1. p = 12, 11, 11 2. p = 13 3. p = 13 4. p = 14 5. q = 67 6. p = 54 7. p = -2 Though I got -2 as my answer to this, when I checked in on my computer it was giving multiple outputs, so each time I run the code, it varies. Why??
Yes , last output gives a fluctuating output bcs the pointer is not pointing to any of the array element and the reason behind this is 1st of all the pointer is pointing to index a[1] (not a[3] as we assume, although in 6th step it's p+2 there's no change in p pointer it's still pointing to p i.e a[1] ) , 2nd p++ is post increment so p++-2 means pointing to a[-1] there's no such location and a random garbage value at this location minus 1 is the answer we are getting for *(p++-2)-1, hence we get fluctuating output
@@yashpatil6670 But how did you get -2? I also 've doubt in it. Just before executing last line: p = &a[1] (also, currently a[1] is =15 ). On execution, (p++ -2) , p is assigned the same (&a[1] ), then incremented (which doesn't matter in this line). so, now it is '&a[1] - 2' (-2 address from current p address), i.e., = &a[-1] ??? So, I thought it should print a garbage value, but it prints 0 for *(p++ -2) and then *(p++ -2) - n = - n. So, here answer is -1..🤷🏽 If you 've any doubt, then check, 1. '(*p++ -1) ' , you get 10 (=a[0]). 2. (*p++) or *p , you get 15 (= current value of a[2]) ?? How does a[-1] get result = 0.. or is there anything wrong in above inference?
Here you will see the exercises listed with some commands that will lead you to their answers. You can also copy the code and run it in your IDE for better understanding. Hope it will help you all. #include int main() { int a[] = {10, 11, -1, 56, 67, 5, 4}; int *p, *q; p = &a[0]; q = &a[0] + 3; printf("--------------- "); printf("1. %d ", *p); // Answer: 10 printf("2. %d ", *q); // Answer: 56 printf("3. %d %d %d ", (*p)++, (*p)++, *(++p)); // Answer: 12 11 11 printf("4. %d ", *p); // Answer: 13 printf("5. %d ", (*p)++); // Answer: 13 printf("6. %d ", (*p)++); // Answer: 14 q--; // q at -1 value printf("7. %d ", (*(q + 2))--); // Answer: 67 printf("8. %d ", (*(p + 2)) - 2); // Answer: 15 printf("9. %d ", *(p++ - 2) - 1); // Answer: garbage value | out of array printf("--------------- "); return 0; }
@@priyanshaaggarwal7723 The expressions are evaluated from right to left. So first *(++p) on the right, then (*p)++ in the middle, then (*p)++ on the left. Initially p points to 10. *(++p) on the right: Pre-increment followed by dereference. p is made to point to the next location first, then the value is printed. So this gives 11 on the right. (*p)++ in the middle: Value at p is first returned, then the value at that location is incremented. (The pointer does not move.) So this gives 11 in the middle. Now the value of a[1] is no longer 11, but 12. (*p)++ on the left: Value at p is first returned, then the value at that location is incremented. (The pointer does not move.) So this gives 12 on the left. Now the value of a[1] is no longer 12, but 13. The array after this step is {10,13,-1,56,67,5,4}.
I got statement number 9 to be -1 after compiling and running the code multiple times. I did not understand the logic for that output. Can someone please explain that last statement?
I am in 12 now ... Unable to relate to anything , still watching 😂 Beauty with Brains 🤠😜 Thanks mam for all the essential vedios u had provided us but our comp exam was cancelled , a hard luck 👍👍👍
ma'am but precedence of post increment /post decrement is greater than pre increment/decrement but you said ++p would be solved first(when second time printf function is used) plz ma'am try to solve my doubt🙏🙏🙏🙏 If someone else is having answer for this then help me out
Assignment submission. i will on types the answers p1: .........12......11.........11 p2........13 p3.........13 p4...........14 p5...........67 p6...............54 p7............-1 but mam, p7 is my problem, how does it give -1 i dont understand. please help
printf("%d",*(p++ -2)-1) in this statement(in assignment qun) after executing till beforer this statement p is at address holding 56 number.as p is post increment, (p++-2) points the p to the address holding -1. then *(p)-1 =-1-1=-2. i guessedd this is the answer. but compiler is showing -1(final answer). could u plz xpalin how this(p++ -2) is working....
(p++-2) is post decrement so p++ is moreover same as p in this line, now p is address of number 15 ,p-2 which is out of array like index -1. so its taking value as 0,atlast -1 is add ,so output is -1.if u change -1 with any number it'll reflect in output
actually the position of pointer doesnot changes until you are not storing it. here we are just having some arithmetic solving .Before the statement you have mentioned the p is holding the value 15 only there was no change in position of pointer
Ma'am... I have watched many of your videos when i wasn't into IT branch.. But now i am learning java and i am not having IT CS background... I literally get irritated while learning program flows.. And i simply don't get it... Please help with some tips.. Much love to you🖤
mam answer is p term is 12 11 11 and in manually I get 12 13 14 in compiler printf("%d",*p) this term is 13 get confused and then 13 13 14 in q term 56 -1 67 54 when last one printf("%d",*(p++ -2)-1) in manual I got 2 in compiler -1 two thing goes doubt and one more p is in 104 address p++ means 108 -2 value is 108 address -1 (-1-2)-1 is that this is correct ?
printf("%d",*(p++ -2)-1) in this statement(in assignment qn) after executing till beforer this statement p is at address holding 56 number.as p is post increment, (p++-2) points the p to the address holding -1. then *(p)-1 =-1-1=-2. this is the answer by theory. but compiler is showing -1,-3 in other compiler,. could u plz expalin how this(p++ -2) is working....
Bruh can u please explain me how the inner statement woks(p++ -2)....bc currently p is in 112(56)...and after doing p++(after using original location then inc..) P is still in 112 & subtracting 2 locations we get 104(11) and after completion we get 11-1==10 this is how i get... Plz correct me bruh
@10:08 Assignment: #include int main() { int a[] = { 10, 11, -1, 56, 67, 5, 4 }; int *p, *q; p = a; q = &a[0] + 3; // commented outputs are in right to left order
q--; // -1 printf("%d ", (*(q + 2))--); // (*(-1 + 2))--) >> (67)-- >> 67 printf("%d ", *(p + 2) - 2); /* *(p + 2) - 2 >> *(11 + 2) - 2 >> *56 - 2 >> 54 */ printf("%d ", *(p++ - 2) - 1); /* *(p++ - 2) - 1 >> *(14 - 2) - 1 >> *12 - 1 >> 11 */ /* line 19 : >> The pointer p points to the element a[1], which has the value 14. >> The expression p + 2 adds 2 to the pointer p, which means that it returns the address of the element a[3], which is two elements ahead of a[1]. >> The expression *(p + 2) dereferences the address returned by p + 2, which means that it accesses the value of the element a[3], which is 56. >> The expression *(p + 2) - 2 subtracts 2 from the value of *(p + 2), which means that it returns 56 - 2, which is 54.
line 20 : >> The pointer p points to the element a[1], which has the value 14. >> The expression p++ - 2 subtracts 2 from the pointer p, which means that it returns the address of the element a[0], which is two elements behind a[1]. Note that p++ also increments p by 1, so that p now points to the element a[2], which has the value -1, but this does not affect the expression p++ - 2, which uses the old value of p. >> The expression *(p++ - 2) dereferences the address returned by p++ - 2, which means that it accesses the value of the element a[0], which is 12. >> The expression *(p++ - 2) - 1 subtracts 1 from the value of *(p++ - 2), which means that it returns 12 - 1, which is 11. */ }
mam,you said we can't perform addition on two pointer variable in previous videos. but now in this video at the end of the program why you added two pointer variables???
hi mam,I am an ECE graduate.Can i attempt CS gate and join CS mtech?If YES,Please tell pros and cons of attempting CS gate and after opportunities mam,Please help mam
Thankyou ma'am for making pointer so easy to understand.. I got the same output as I have solved it on paper. Only last line is giving -1 as output but i am getting -2 on paper. Thankyou ma'am💛
3:08 can anyone plz explain me that int a[ ] this bracket should have value 10 according to number of elements in array but she took 100.....? Why yaar plz koi samjado mujhe plz🙏
@@gyanendarkaur2283 she assume the 100 to be the address of the first index in the array . Remember int a is automatically storing the address of the first index
@@gyanendarkaur2283 it's not array index , it's 1st array element's address in memory , she has taken 100 for easy understanding, although address in memory is usually in hexadecimal form
@@nanditagiridharan1197 Guys can anyone explain why printf("%d ",*(p++ -2)-1); this line giving -1 output, Because My logics are not working on paper..... If I run it on online compiler its giving Garbage value and On VS code its Giving -1.... No idea whats happening, According to me it should give another answer
@@flames_tech If we apply proper logic we will get the output as -1 itself , because in the last second step p is pointing to 4th element(56) right.........so in the last step p is currently pointing to address of (56) ,then as per question brackets hv higher precedence......so inside brackets we hv (p++ -2) where ±± increment operator has higher precedence so p is now pointing to (67) and then -2 suggests taking pointer p back by 2 positions i.e now p is pointing to address of (-1)............then once we solved within the brackets we have *(address of(-1 )) - 1........so * operator has higher precedence therefore print -1 as output and finally [ in array -1-1=-2 will be stored in that location but it wont reflect in the output ].............hence the output -1 ! Hope it's clear.....
I open the video because of ur picture in thumbnail and then realized that it's a programming video.....and now I have learned most of the topic of C ...🤣🤣🤣🤣🤣🤣
Hi jenny I tried manually first am able to trace most of the questions only three things I have a doubt. If it's possible, could you please help give an explanation for below one. 1. printf("(*(q+2)--)=%d ",(*(q+2))--); -> for this my manual output and the compiler output is same but after this statement i tried to print *q but the compiler shows -1 value, but my manual output is 56 am confused why this difference can you please give answer for this. 2. printf("*(p++ -2)-1=%d ",*(p++ -2)-1); -> can you please explain this also.
2nd Qn is a real doubt. My observations are given below: Just before executing last line: p = &a[1] (also, currently a[1] is =15 ). On execution, (p++ -2) , p is assigned the same (&a[1] ), then incremented (which doesn't matter in this line). so, now it is '&a[1] - 2' (-2 address from current p address), i.e., = &a[-1] ??? So, I thought it should print a garbage value, but it prints 0 for *(p++ -2) and then *(p++ -2) - n = - n. So, here answer is -1.. If you 've any doubt, then check, 1. '(*p++ -1) ' , you get 10 (=a[0]). 2. (*p++) or *p , you get 15 (= current value of a[2]) ?? How does a[-1] get result = 0.. or is there anything wrong in above inference?
3:08 can anyone plz explain me that int a[ ] this bracket should have value 10 according to number of elements in array but she took 100.....? Why yaar plz koi samjado mujhe plz🙏
@@gyanendarkaur2283 when u declare a variable containing an array of numbers the variable declared automatically hold the address of the first element in the array. Jenny just assume 100 to be the address of the first element int the array that is why is storing 100. You can also say it a pointer holding the address of the first element in the array. I hope this help.
3:08 can anyone plz explain me that int a[ ] this bracket should have value 10 according to number of elements in array but she took 100.....? Why yaar plz koi samjado mujhe plz🙏🙏
@@gweri91 opertors with same precedence are present, so associativity is from right to left in those operators , you can check the precedence table of operators for C.
@@moonscope1148 I have the table but ( ) and post increment has higher precedence right. So in (*p)++,*p++,*p++ why evaluate *++p first rather than (*p)++
Mam 12 th science se karne k bad agar mai computer field mai jana cahtu hu to mare liye bca ya bsc in cs acha rhega, Kounsa course lane chahiye . Please help mam 🙏
In the statement printf("%d %d %d
", (*p)++, *p++, *++p);, it might seem that the operations should be evaluated from right to left due to operator precedence or associativity, but that's not how function argument evaluation works in C.
Understanding the Concept:
Operator Associativity vs. Function Argument Evaluation:
Operator Associativity refers to how operators of the same precedence are grouped in the absence of parentheses (e.g., a + b + c is left-to-right because + is left-associative).
However, function arguments in C are not evaluated based on the associativity of the operators within the arguments. Instead, the order of evaluation of function arguments is unspecified in the C standard.
Unspecified Evaluation Order in C: The C standard does not define the exact order in which function arguments are evaluated (i.e., whether arguments are evaluated left-to-right, right-to-left, or in any particular order). This means that depending on the compiler, the order can vary. Most modern compilers tend to evaluate arguments from right to left, but it’s not guaranteed, and the standard doesn’t mandate it.
Side Effects with Increment Operators: In this case, the post-increment and pre-increment operators (++) introduce side effects, which change the value of p (the pointer) during argument evaluation. This makes it tricky to predict the exact output without knowing how the compiler evaluates the function arguments.
Example Breakdown:
Let’s analyze what happens in the statement printf("%d %d %d
", (*p)++, *p++, *++p);.
(*p)++:
This returns the value that p points to (dereferenced), then increments the value at p.
*p++:
This returns the current value at p, then increments the pointer p to point to the next location.
*++p:
This first increments the pointer p, then returns the value at the new location.
Now, based on how the compiler decides to evaluate the arguments, the exact order of pointer increments and dereferencing will differ.
Why Associativity Doesn’t Apply:
Operator associativity applies when you have multiple operators of the same precedence in a single expression (like a + b + c).
Function argument evaluation is not governed by associativity rules but by the fact that the C standard leaves the order of evaluation unspecified. Therefore, associativity doesn't determine how arguments like (*p)++, *p++, and *++p are evaluated.
Conclusion:
The evaluation order of the arguments in printf is unspecified, meaning the compiler can choose the order in which these arguments are processed. This is why associativity (whether right-to-left or left-to-right) does not govern the behaviour here. The key takeaway is to avoid relying on the evaluation order when using side-effect-producing expressions like ++ in function arguments, as the result may vary across compilers.
I put the code on chatgpt and it gave output different than gcc compiler. Thanks, your comment was helpful.
thank you!
wow. Studying become more interesting after such problems....especially for beginners
Jenny the Robot. Happy Independence Day Mam.
ruclips.net/video/r2xHolThGj4/видео.html
I think that pointer topic is so tough...but when I saw your lecture it so simple ..for me ,thank you mam...really that you given problem are make practice
Thank you mam for a wonderful explanation . Mam I have one that is we are going to get the output of star p as zero in that case why the value got changed in place of -1 to 0 . In the first code problem.
thanks mam for helping us specially in present era..it is a very famous maxim that people help u ,u r lucky if people don't help u its very common.i have seen 1st 20 video in a day ..all are quite interesting and understandable. I have learnt more.thsnks
Your way of teaching is unique. Love and respect from Pakistan❤
ily
1. p = 12, 11, 11
2. p = 13
3. p = 13
4. p = 14
5. q = 67
6. p = 54
7. p = -2 Though I got -2 as my answer to this, when I checked in on my computer it was giving multiple outputs, so each time I run the code, it varies. Why??
How -2?
Pl type here this code
Yes , last output gives a fluctuating output bcs the pointer is not pointing to any of the array element and the reason behind this is 1st of all the pointer is pointing to index a[1] (not a[3] as we assume, although in 6th step it's p+2 there's no change in p pointer it's still pointing to p i.e a[1] ) , 2nd p++ is post increment so p++-2 means pointing to a[-1] there's no such location and a random garbage value at this location minus 1 is the answer we are getting for *(p++-2)-1, hence we get fluctuating output
Because in question there is
P=a not p=&a
yes bro why?
how to understand the assossiactivity at 2:48 that it is right to left ??
for printf statement the assossiactivity is right to left
Thanks very much for the well-detailed video. It clear my conceptions on pointer.
but didn't mam say that we cannot add two pointers
Ma'am it's a request please make a course on Java also.
U teach amazingly
Thank you ma'am
Durga soft for java
At 11:00, In printf("%d
", *(p++-2)-1) , my calculation is coming -2, but the output is showing -3. Plz explain it.
My compiler gives -1 while according to my calc it's -2
@@sumitno10 same condition here
@@Lokesh_yadav__ here also same output is -1 but i guess -2 or (14 while p is post icrement)
It is suppose to return a garbage value
I can explain if you want
8:56 why are we geeting -3 for the last one when i dry i get -2
Yes, I also got -2
@@yashpatil6670 But how did you get -2? I also 've doubt in it.
Just before executing last line:
p = &a[1] (also, currently a[1] is =15 ).
On execution, (p++ -2) , p is assigned the same (&a[1] ), then incremented (which doesn't matter in this line). so, now it is '&a[1] - 2' (-2 address from current p address), i.e., = &a[-1] ???
So, I thought it should print a garbage value, but it prints 0 for *(p++ -2) and then *(p++ -2) - n = - n. So, here answer is -1..🤷🏽
If you 've any doubt, then check,
1. '(*p++ -1) ' , you get 10 (=a[0]).
2. (*p++) or *p , you get 15 (= current value of a[2])
?? How does a[-1] get result = 0.. or is there anything wrong in above inference?
Your way of explanation is always awesome, very enjoyable, interesting and easy to absorb. Thank you so much!!! Keep up the good work☺
Nice t-shirt, nice hair, introducing you self is professional,
Thinking imagination,
Respected,
ruclips.net/video/r2xHolThGj4/видео.html
🌟🌟Mam, when will you upload Object Oriented Programming (OOPs)videos mam, waiting alot to see !!!!!! 🌟🌟
4:38 mam but *p is in bracket so first it should have been solve plz reply mam
Best question to practice 👌thank you❤
Mam I didn't get the last printf statement *(p++ -2)-1; in the assignment you gave.
Thank you ma'am for such wonderful explanation....
Mam your voice sounds exactly of a strict teacher.
i got (-3) on the last one any explainations why i got that ? i tried the code on the white board not the one on the computer.
Ma'am please upload remaining lectures of pointer and also make videos on structure and function
Here you will see the exercises listed with some commands that will lead you to their answers. You can also copy the code and run it in your IDE for better understanding. Hope it will help you all.
#include
int main() {
int a[] = {10, 11, -1, 56, 67, 5, 4};
int *p, *q;
p = &a[0];
q = &a[0] + 3;
printf("---------------
");
printf("1. %d
", *p); // Answer: 10
printf("2. %d
", *q); // Answer: 56
printf("3. %d %d %d
", (*p)++, (*p)++, *(++p)); // Answer: 12 11 11
printf("4. %d
", *p); // Answer: 13
printf("5. %d
", (*p)++); // Answer: 13
printf("6. %d
", (*p)++); // Answer: 14
q--; // q at -1 value
printf("7. %d
", (*(q + 2))--); // Answer: 67
printf("8. %d
", (*(p + 2)) - 2); // Answer: 15
printf("9. %d
", *(p++ - 2) - 1); // Answer: garbage value | out of array
printf("---------------
");
return 0;
}
for 8. ans is 54
How 3 is 12 11 11 ?
@@priyanshaaggarwal7723
The expressions are evaluated from right to left. So first *(++p) on the right, then (*p)++ in the middle, then (*p)++ on the left.
Initially p points to 10.
*(++p) on the right:
Pre-increment followed by dereference.
p is made to point to the next location first, then the value is printed. So this gives 11 on the right.
(*p)++ in the middle:
Value at p is first returned, then the value at that location is incremented. (The pointer does not move.)
So this gives 11 in the middle. Now the value of a[1] is no longer 11, but 12.
(*p)++ on the left:
Value at p is first returned, then the value at that location is incremented. (The pointer does not move.)
So this gives 12 on the left. Now the value of a[1] is no longer 12, but 13.
The array after this step is {10,13,-1,56,67,5,4}.
I got statement number 9 to be -1 after compiling and running the code multiple times. I did not understand the logic for that output. Can someone please explain that last statement?
@@itsmeshyam1436 Which was statement number line?
Hello mam,
I Ioved and learned more from your videos thanku so much
Happy independence day mam tq for helping us to achieve our goals 😀😍🇮🇳🇮🇳
ruclips.net/video/r2xHolThGj4/видео.html
tq
JAISHREERAMSITARAKRISHNARADHKRISHNA
I am in 12 now ... Unable to relate to anything , still watching 😂
Beauty with Brains 🤠😜
Thanks mam for all the essential vedios u had provided us but our comp exam was cancelled , a hard luck 👍👍👍
relax kid
Bud yhi krna tum🤣
ma'am but precedence of post increment /post decrement is greater than pre increment/decrement but you said ++p would be solved first(when second time printf function is used) plz ma'am try to solve my doubt🙏🙏🙏🙏
If someone else is having answer for this then help me out
ma'am plz do not ignore this comment🙏🙏🙏🙏
Are bro associativity check karo.
Our iski associativity left to right hai.
Yes she has given wrong info little bit , 7:02 it is left to right she said it’s right to left
@@lillyput2275 Can you please explain at 4:15 for
(*p)++, *p++,*++p why we took assosciativity right to left
@@gweri91 unary operators having associativity right to left
I watch your videos from Argentina. Keep up the good work.
U r on social media like Telegram or twitter ?
Assignment submission. i will on types the answers
p1: .........12......11.........11
p2........13
p3.........13
p4...........14
p5...........67
p6...............54
p7............-1
but mam, p7 is my problem, how does it give -1 i dont understand. please help
Yes how does I too have same doubt.
You are wrong
same here i don't get
printf("%d",*(p++ -2)-1) in this statement(in assignment qun) after executing till beforer this statement p is at address holding 56 number.as p is post increment, (p++-2) points the p to the address holding -1. then *(p)-1 =-1-1=-2. i guessedd this is the answer. but compiler is showing -1(final answer). could u plz xpalin how this(p++ -2) is working....
(p++-2) is post decrement so p++ is moreover same as p in this line, now p is address of number 15 ,p-2 which is out of array like index -1. so its taking value as 0,atlast -1 is add ,so output is -1.if u change -1 with any number it'll reflect in output
actually the position of pointer doesnot changes until you are not storing it. here we are just having some arithmetic solving .Before the statement you have mentioned the p is holding the value 15 only there was no change in position of pointer
Could you please tell the output of the 1st printf statement of this example?
@@invincible9971 12 11 11
Can you please explain last 3 outputs?
3:56 mam isme doubt h. Jb number icreament hui to uski adress v to change hogi?
Please answer 🙏🏻
Ma'am... I have watched many of your videos when i wasn't into IT branch.. But now i am learning java and i am not having IT CS background... I literally get irritated while learning program flows.. And i simply don't get it... Please help with some tips.. Much love to you🖤
Please explain last one
@jenney's lecture CS/IT NET&JRF last out I go -2 but when I run got -3
Same doubtt
mam answer is p term is 12 11 11 and
in manually I get 12 13 14 in compiler printf("%d",*p) this term is 13 get confused and then 13 13 14 in q term 56 -1 67 54 when last one printf("%d",*(p++ -2)-1) in manual I got 2 in compiler -1
two thing goes doubt and one more p is in 104 address p++ means 108 -2 value is 108 address -1 (-1-2)-1 is that this is correct ?
Well respected madam zi,
Introducing this exceeding program,
Must notify
i love your teaching style❤❤
You taught we can't add two pointers
Ma'am what is the difference between p=&a and p=a
If P is a pointer then in 1st case p will store the address of a
As long as p is a pointer you can store the address of a by using p=&a or p=a.
Mam maza aagya 😊
Mam please continue C programming playlist
printf("%d",*(p++ -2)-1) in this statement(in assignment qn) after executing till beforer this statement p is at address holding 56 number.as p is post increment, (p++-2) points the p to the address holding -1. then *(p)-1 =-1-1=-2. this is the answer by theory. but compiler is showing -1,-3 in other compiler,. could u plz expalin how this(p++ -2) is working....
i got this as answer for this statement 32765
it doesnt make sense
Bruh can u please explain me how the inner statement woks(p++ -2)....bc currently p is in 112(56)...and after doing p++(after using original location then inc..) P is still in 112 & subtracting 2 locations we get 104(11) and after completion we get 11-1==10 this is how i get... Plz correct me bruh
same problem
why the printf function will start executing from the last value backwards !!!?
It's following the LIFO rule in the execution of stacks
Mam upload python videos also💥✨
Thank you ma'am keep it up with lot's of problems. It is always good to learn for success
@10:08 Assignment:
#include
int main()
{
int a[] = { 10, 11, -1, 56, 67, 5, 4 };
int *p, *q;
p = a;
q = &a[0] + 3;
// commented outputs are in right to left order
printf("p = %d
", *p); // 10
printf("q = %d
", *q); // 56
printf("%d %d %d
", (*p)++, (*p)++, *(++p)); // 11, 11, 12
printf("%d
", *p); // 13
printf("%d
", (*p)++); // 13
printf("%d
", (*p)++); // 14
q--; // -1
printf("%d
", (*(q + 2))--); // (*(-1 + 2))--) >> (67)-- >> 67
printf("%d
", *(p + 2) - 2); /* *(p + 2) - 2 >> *(11 + 2) - 2 >> *56 - 2 >> 54 */
printf("%d
", *(p++ - 2) - 1); /* *(p++ - 2) - 1 >> *(14 - 2) - 1 >> *12 - 1 >> 11 */
/*
line 19 :
>> The pointer p points to the element a[1], which has the value 14.
>> The expression p + 2 adds 2 to the pointer p, which means that it returns the address of the element a[3], which is two elements ahead of a[1].
>> The expression *(p + 2) dereferences the address returned by p + 2, which means that it accesses the value of the element a[3], which is 56.
>> The expression *(p + 2) - 2 subtracts 2 from the value of *(p + 2), which means that it returns 56 - 2, which is 54.
line 20 :
>> The pointer p points to the element a[1], which has the value 14.
>> The expression p++ - 2 subtracts 2 from the pointer p, which means that it returns the address of the element a[0], which is two elements behind a[1]. Note that p++ also increments p by 1, so that p now points to the element a[2], which has the value -1, but this does not affect the expression p++ - 2, which uses the old value of p.
>> The expression *(p++ - 2) dereferences the address returned by p++ - 2, which means that it accesses the value of the element a[0], which is 12.
>> The expression *(p++ - 2) - 1 subtracts 1 from the value of *(p++ - 2), which means that it returns 12 - 1, which is 11.
*/
}
galat hain...
Output is
12,12,11
11
12
12
66
54
10
Right ??
Mam pointers ke aage videos upload kijie jaldi pls 😅.
Waiting eagerly for next video and one request to you daily upload one video ☺️
Mam we need answer 9:13 plz mam
Mam why ur not uploading videos
IAM waiting for further chapters.
Please try to make it fast and smooth 😊🙏
mam,you said we can't perform addition on two pointer variable in previous videos. but now in this video at the end of the program why you added two pointer variables???
the pointers were not added, the values to which the pointers were pointing to were added
9.57 how is addition of 2 pointers is possible mam?
In C_75 (addition) video...u have told addition of two pointers is not possible. Then how mam?
P+q is not possible but *p+*q is possibe
Why is the printf function evaluating from right to left but printin them left to right...This is like something undefined behaviour..
4:16 what about precedence
Ma'am why are you not uploading next lectures of pointer now
mam, why did u write p=a?? but actually pointer stores address of a right??
the array name holds the base address of the array, hence they are often referred to as
"internal pointer variable"
Hi miss!!
Your smile is like my favorite actresses : -
Shruti Sharma and Rashmika Manndana!!!
You are amazing mam , I wish I will meet with you ...😊
1. 12 11 11
2. 13
3. 13
4. 14
5. 67
6. 54
7. -2
Thanks mum. i was able to do this with ease
Do we get - 2 or any other garbage value for last one
@@nikithaa.s683i got - 2 on paper but the compiler showed a garbage value
@@devSackey okey tq
Shouldn't no. 5 be 66?
@@goplay5936 no bro its should be 67. Cross check with your compiler to confirm
Mam c++ bhi sikao na
Happy Independence Day Mam
ruclips.net/video/r2xHolThGj4/видео.html
JAISHREEGANESHHARHARMAHADEVMATAJI
yrrrr..ye mam kitti awesome hai yaaar
hi mam,I am an ECE graduate.Can i attempt CS gate and join CS mtech?If YES,Please tell pros and cons of attempting CS gate and after opportunities mam,Please help mam
Ma'am Please 🙏 Java ka course bhi start kar de it''s a request. Lots of love and respect for you from Pakistan.
Could any of you people help me with the last line of the code where it's getting an error.
Happy Independence Day Ma'am🇮🇳🇮🇳
ruclips.net/video/r2xHolThGj4/видео.html
JAISHREEOMSAIRAM
love you mam first time I tried and i got right
ma'am the assignment which gave you to us i tried it but it gives garbage values
Mam pls upload more videos on C as soon as possible mam
Answers are:
12 11 11
13
13
14
67
54
some garbage values
Correct bro
@@pavankumarreddy9586 i know
@@learningwithankit8701 👍
Can you say ,why last one ans is garbage values?
can u plz explain y the last value garbage value
thanks mam. it will help
in the gate
Happy teacher's day mam
Thankyou ma'am for making pointer so easy to understand.. I got the same output as I have solved it on paper. Only last line is giving -1 as output but i am getting -2 on paper. Thankyou ma'am💛
3:08 can anyone plz explain me that int a[ ] this bracket should have value 10 according to number of elements in array but she took 100.....? Why yaar plz koi samjado mujhe plz🙏
@@gyanendarkaur2283 she assume the 100 to be the address of the first index in the array . Remember int a is automatically storing the address of the first index
@@gyanendarkaur2283 it's not array index , it's 1st array element's address in memory , she has taken 100 for easy understanding, although address in memory is usually in hexadecimal form
@@nanditagiridharan1197 Guys can anyone explain why printf("%d
",*(p++ -2)-1); this line giving -1 output, Because My logics are not working on paper..... If I run it on online compiler its giving Garbage value and On VS code its Giving -1.... No idea whats happening, According to me it should give another answer
@@flames_tech If we apply proper logic we will get the output as -1 itself , because in the last second step p is pointing to 4th element(56) right.........so in the last step p is currently pointing to address of (56) ,then as per question brackets hv higher precedence......so inside brackets we hv (p++ -2) where ±± increment operator has higher precedence so p is now pointing to (67) and then -2 suggests taking pointer p back by 2 positions i.e now p is pointing to address of (-1)............then once we solved within the brackets we have *(address of(-1 )) - 1........so * operator has higher precedence therefore print -1 as output and finally [ in array -1-1=-2 will be stored in that location but it wont reflect in the output ].............hence the output -1 !
Hope it's clear.....
When c program last vedio will updated
Thanks for the quiz. I thought I understood it well till I tried them out.
What's answer??
Can you explain??
12,11,11
13
13
14
67...
Why 67???
Can you explain it??
And last one -3..why??
@@meghamoni6626 67 because the line of q--
6:34 mam ye kese pata chalega right se karna hai ya left se
Precedence order hain ek .Follow the upper videos of the playlist.
Abha muje chakkar ane lage ha 🥴......
just kidding I like the way you teach.. (thank you 😊...)
Mam In second prinf you discussed about first %d is value is zero but we are getting -1
It's a post increment
First value will be assigned that is -1
and will be incremented to 0
Next line u are getting 0.😊
As per my calculation first printf statement output should be 12 11 11 but i got 10 11 11 how ??
Same 😢
I open the video because of ur picture in thumbnail and then realized that it's a programming video.....and now I have learned most of the topic of C ...🤣🤣🤣🤣🤣🤣
Gujarati English accent🤩🤩👍👍
Thanks for your efforts mam
Hi jenny I tried manually first am able to trace most of the questions only three things I have a doubt. If it's possible, could you please help give an explanation for below one.
1. printf("(*(q+2)--)=%d
",(*(q+2))--); -> for this my manual output and the compiler output is same but after this statement i tried to print *q but the compiler shows -1 value, but my manual output is 56 am confused why this difference can you please give answer for this.
2. printf("*(p++ -2)-1=%d
",*(p++ -2)-1); -> can you please explain this also.
Can you share your full code? I'm confident to help you clear your 1st doubt, I got the answer in dry run and in compiler run.
2nd Qn is a real doubt. My observations are given below:
Just before executing last line:
p = &a[1] (also, currently a[1] is =15 ).
On execution, (p++ -2) , p is assigned the same (&a[1] ), then incremented (which doesn't matter in this line). so, now it is '&a[1] - 2' (-2 address from current p address), i.e., = &a[-1] ???
So, I thought it should print a garbage value, but it prints 0 for *(p++ -2) and then *(p++ -2) - n = - n. So, here answer is -1..
If you 've any doubt, then check,
1. '(*p++ -1) ' , you get 10 (=a[0]).
2. (*p++) or *p , you get 15 (= current value of a[2])
?? How does a[-1] get result = 0.. or is there anything wrong in above inference?
Ma'am I'm not able to understand how the last one is a random value...
is anyone else getting a warning of unsequenced modification?
The statement : printf("%d",(*(q+2)--) is showing an error => lvalue required as decrement operand
3:08 can anyone plz explain me that int a[ ] this bracket should have value 10 according to number of elements in array but she took 100.....? Why yaar plz koi samjado mujhe plz🙏
@@gyanendarkaur2283 when u declare a variable containing an array of numbers the variable declared automatically hold the address of the first element in the array. Jenny just assume 100 to be the address of the first element int the array that is why is storing 100. You can also say it a pointer holding the address of the first element in the array.
I hope this help.
Did u end it with a semi Column ??
Same here
I have too many errors on my system which was not expected according to my logic 😆
Ma'am
make a video Job's on without coding and programming.
Mam I run that program in my compiler but not correctly showing all values , can you please help me
#jenny lecture's
the output of *(p++ - 2) - 2 is showing -1 in my machine, but couldn't understand why please explain ma'am.
3:08 can anyone plz explain me that int a[ ] this bracket should have value 10 according to number of elements in array but she took 100.....? Why yaar plz koi samjado mujhe plz🙏🙏
@@gyanendarkaur2283 that 100 is the address of first element of the array, its just a assumption.
Can you please explain at 4:15 for
(*p)++, *p++,*++p why we took assosciativity right to left
Plz🙏
@@gweri91 opertors with same precedence are present, so associativity is from right to left in those operators , you can check the precedence table of operators for C.
@@moonscope1148 I have the table but ( ) and post increment has higher precedence right. So in
(*p)++,*p++,*p++
why evaluate *++p first rather than (*p)++
Good morning mam
mam how to start gate preparation in my 1st year. will you plz tell me tips and best online resources🙏🙏🙏
Mam, after this pointers concept please make vedios on functions concept.
vedios
@@arjungaur1098 may be autocorrect is incorrect this or may be this word from whatsapp University. but it's ok we need to understand what he said.
Mam why you are not uploading remaining videos
Happy independence day mam
ruclips.net/video/r2xHolThGj4/видео.html
JAIBHAWANISHIVAJIMAHARAJKIJAI
After running the last example,l am getting 10
10 11 -1
-1
2
16
16
Mam 12 th science se karne k bad agar mai computer field mai jana cahtu hu to mare liye bca ya bsc in cs acha rhega,
Kounsa course lane chahiye .
Please help mam 🙏
Mam you are so cute ❣️❣️❣️❣️❣️❣️❣️❣️❣️❣️❣️❣️❣️❣️❣️
Why I got -2 for the last statement but it shows 32766 or 32733 on my screen? Could someone plz explain to me
Mam please make video on how to print alphabet x or b in the pattern form Using * symbol in c language
There are many videos of mam available on the channel "patterns in c" .
When u will start the daa playlist Madam
Can anyone please tell me which book is best for C language.
Let Us C (17th Edition) Go for it
@@Shanya568 jennys lectures are more than enough if u watch all classes properly