13:59 int a[]={3,2,67,0,56}; int *p; p=&a[3]; in increment decrement it has right to left precedence, So the 3rd (*--p) will be solved frst the 3rd *--p will decrement and then the value of p will be used for the next expression initial value for *p=a[3] = 0 3rd. *--p = decrement to a[2] = 67 2nd. *--p= decrement to a[1] = 2 1st. *--p= decrement to a[0] = 3 output:- 3 2 67
16:04 printf ("%d %d", *p++ , *p++); // ABNORMALITY in this Code.. The post - inc/dec has associativity , L -> R . But the result, shown seems to be executed from R -> L ('2 3' is output instead of '3 2'). From chatgpt, "The order of evaluation, of function arguments is unspecified in C. It may vary with compilers." printf is a function and here each p++ may be an argument. Hence the variation in order. Conclusion : It's better to not use, more than 1 increment or decrement operator in a Single line of code , to avoid abnormal behaviour. By the way, Thanks Jenny for this amazing lecture series❤
Also, I read that, arguments of printf are evaluated from Right to Left ⬅️ . But when I printed, printf("%d %p", *p++, p); // result= a[0] &a[1] printf("%d %p", *p, p++); // result= a[1] &a[0] It means, whatever the order is, argument with increment is executed at 1st, (for post-inc, the original value of the p is assigned for the ++ argument and then incremented for the next argument. for *p++, it is assigned with address of p and print a[0], Now p= &a[1], and it is printed in the place of p. for p++, it is assigned with address of a[0] and print a[0], Then p is incremented, p=&a[1] and *p = a[1] is printed. Conclusion again : Inc/dec operator itself is dangerous☠️😅
#include int main(void) { int a[] = {3, 2, 67, 0, 56}; int *p = &a[3]; printf("%d %d %d", *--p, *--p, *--p); return 0; } This will give 67, 2, 3 Assosciativity is Right to left so the first *--p at the end is evaluated and since it's pre decrement p moves from holding the address of p[3] to p[2] so this prints the value 67, the next *--p moves from p holding address of p[2] to p[1] so value at p[1] which is 2 is printed. The last *--p moves p from holding address of p[1] to address of p[0]. It prints value 3 that is at p[0]
the basic difference between *p++ is here we are incrementing the adresses but in case of (*p)++ means we are incremwnting its value: eg:-> int a[5]={50,1,-1,10,18}; int *p=&a[4]; printf("%d ",(*p)--);// ans= 18 printf("%d ",*p);// ans=17 in case of :-> int a[5]={50,1,-1,10,18}; int *p=&a[4]; printf("%d ",*p--);// ans= 18 printf("%d ",*p);// ans=10
Thank u so much sister for spreading your knowledge... I like very much the way of your teaching... Keep support us and we will always support you sister... Thank u thank u so much....
#include int main(void) { int a[] = {3, 2, 67, 0, 56}; int *p = &a[3]; printf("%d ", --(*p)); printf("%d ", (*p)++); printf("%d ", ++(*p)); return 0; } This will give -1, -1, 1 In the first printf, *p value is 0 then with pre decrement it becomes -1 In the second printf *p is -1 so it's -1++ which is post increment so -1 is printed but the actual value is now 0. In the third printf it's pretty increment so the 0 becomes 1
Ma'am can you start some coding from geeks for geeks, it will be a great help if you start placement series, from geeks for geeks, Hacker and leet codes.
Ma'am you said associativity of post increment and decrement is left to right and associativity of pre increment and decrement is right to left in your previous video of associativity video
#include int main() { int a[ ]={3, 2, 67, 0, 56}; int *p=&a[0]; printf("%d", ++*p); return 0; } out puts 4 Would like to share this at 1st p prints 3 as the aesterick marks it at the base index Then increments the value which is 3 by 1 to out put 4 at the console .
n a standard C environment, the expressions ++*p and *p++ are distinct and have different behaviors. ++*p is the pre-increment operator applied to the value pointed to by p. It increments the value before it is used in the expression. So if p points to 3, then ++*p increments 3 to 4, and 4 is the result used in any further expression. *p++ is the dereference operator applied to the value pointed to by p, followed by the post-increment operator applied to the pointer p itself. It dereferences the value (fetches the value 3 in this case) and then increments the pointer to point to the next element in the array after accessing the value. The result used in the expression is the original value before the pointer was incremented.
thanks for the lecture im learning a lot thanks to you I have just a little concern on this topic on incrementation and deference that can happen , I don't know why on your computer is giving you this strange results. In a standard C environment, the expressions ++*p and *p++ are distinct and have different behaviors. ++*p is the pre-increment operator applied to the value pointed to by p. It increments the value before it is used in the expression. So if p points to 3, then ++*p increments 3 to 4, and 4 is the result used in any further expression. *p++ is the dereference operator applied to the value pointed to by p, followed by the post-increment operator applied to the pointer p itself. It dereferences the value (fetches the value 3 in this case) and then increments the pointer to point to the next element in the array after accessing the value. The result used in the expression is the original value before the pointer was incremented.
char ch =x; char *pch=&ch; printf(" uppercase is %c",*pch-32); output = X; according to what you said *pch should return x's address right ? or increment/decrement different from adding integers ?? please clarify doubt ..........
bro in the print statement u use that indirectionor dereference operator so only its given captial X i think so but i'm not sure about my answer are correct
I wrote this program in visual studio #include #include int main() { int a[] = { 1,2,3,4,5 }; int* p; p = a; //p = p + 4; printf("%d ", *p); printf("%d %d %d ", *++p, *++p, *++p); return 0; } Output is: 1 4 4 4 It looks to me first it is incrementing the value p 3 times and the start printing. ---------------------------- Same observation in pre-decrementing. --------------------------- Anything has been changed ?
13:59
int a[]={3,2,67,0,56};
int *p;
p=&a[3];
in increment decrement it has right to left precedence, So the 3rd (*--p) will be solved frst
the 3rd *--p will decrement and then the value of p will be used for the next expression
initial value for *p=a[3] = 0
3rd. *--p = decrement to a[2] = 67
2nd. *--p= decrement to a[1] = 2
1st. *--p= decrement to a[0] = 3
output:- 3 2 67
I guess 2,3 and garbage value bro..
@@flames_tech no, because he set *p=a[3] ! his result is true !
@@nguyendinhbac7165 but ma'am changed it to a[2] later
You are right 👍
@@flames_tech
p++ pahle print kro phir increment kro
++p pahle increment kro phir print kro
16:04 printf ("%d %d", *p++ , *p++); // ABNORMALITY in this Code..
The post - inc/dec has associativity , L -> R .
But the result, shown seems to be executed from R -> L ('2 3' is output instead of '3 2').
From chatgpt, "The order of evaluation, of function arguments is unspecified in C. It may vary with compilers."
printf is a function and here each p++ may be an argument. Hence the variation in order.
Conclusion : It's better to not use, more than 1 increment or decrement operator in a Single line of code , to avoid abnormal behaviour.
By the way, Thanks Jenny for this amazing lecture series❤
Also, I read that, arguments of printf are evaluated from Right to Left ⬅️ . But when I printed,
printf("%d %p", *p++, p); // result= a[0] &a[1]
printf("%d %p", *p, p++); // result= a[1] &a[0]
It means, whatever the order is, argument with increment is executed at 1st, (for post-inc, the original value of the p is assigned for the ++ argument and then incremented for the next argument.
for *p++, it is assigned with address of p and print a[0], Now p= &a[1], and it is printed in the place of p.
for p++, it is assigned with address of a[0] and print a[0], Then p is incremented, p=&a[1] and *p = a[1] is printed.
Conclusion again : Inc/dec operator itself is dangerous☠️😅
14:59 answer is garbage value,3,2
Next one answer is
Segmentation fault
Correct aa bro
@@nikhilpragada1562 next ans will be 1012 1012 1012
2:15 lecture starts
The teacher's lectures are amazing! greetings from Vietnam !
The answer is garbage value, 3, 2;
Youve made pointers so easy mum;
#include
int main(void)
{
int a[] = {3, 2, 67, 0, 56};
int *p = &a[3];
printf("%d %d %d", *--p, *--p, *--p);
return 0;
}
This will give 67, 2, 3
Assosciativity is Right to left so the first *--p at the end is evaluated and since it's pre decrement p moves from holding the address of p[3] to p[2] so this prints the value 67, the next *--p moves from p holding address of p[2] to p[1] so value at p[1] which is 2 is printed. The last *--p moves p from holding address of p[1] to address of p[0]. It prints value 3 that is at p[0]
the basic difference between *p++ is here we are incrementing the adresses but in case of (*p)++ means we are incremwnting its value:
eg:->
int a[5]={50,1,-1,10,18};
int *p=&a[4];
printf("%d
",(*p)--);// ans= 18
printf("%d
",*p);// ans=17
in case of :->
int a[5]={50,1,-1,10,18};
int *p=&a[4];
printf("%d
",*p--);// ans= 18
printf("%d
",*p);// ans=10
Thanks dude
thanks
11:06
printf("%d %d",*p++ ,*p++);
it is undefined behaviour. my compiler(visual studio 2019) returns 3 -3 for example.
1st ans is garbage value,3,2
At 11:29 it should be 3,2 as associativity is from left to right .
I too have that doubt
Associativity is from right to left, (
And answer is also correct, it would be 2 3
@@SN-edits4u my compiler returned 3,2. Can you please explain why?
Thanks my teacher for everything ❤️🌹I understood this lesson after I have saw your episode
Jenny the Robot
🤖
😂
So true 😂
Yes
Omggg 💯 💯 💯 💞
Thank you so much mam,your are the best teacher i never ever saw in my life,your teaching skills amazing❤
At 11:00
When i run
printf("%d %d",*p++,*p++);
my output coming is. : 3 2
But according to you it should be 2 3.
Same iam getting
Can u pls tell in which complier u are performing programs?
It is post increment associativity is from left to right
In pre-increment associativity is from right to left
See 17:40
Actually different compilers have different order of evaluation of printf statement
Generally it is right to left
Your explanation are so simple and easy to understand. I'm studying programming fundamentals and your videos helped me so much. Thank you very much 🙏🙏
Your every video is very clear mam. Thanks for your understandable lecture ☺️
Thank u so much sister for spreading your knowledge... I like very much the way of your teaching... Keep support us and we will always support you sister... Thank u thank u so much....
#include
int main(void)
{
int a[] = {3, 2, 67, 0, 56};
int *p = &a[3];
printf("%d
", --(*p));
printf("%d
", (*p)++);
printf("%d
", ++(*p));
return 0;
}
This will give -1, -1, 1
In the first printf, *p value is 0 then with pre decrement it becomes -1
In the second printf *p is -1 so it's -1++ which is post increment so -1 is printed but the actual value is now 0.
In the third printf it's pretty increment so the 0 becomes 1
Wish to present before you &thank you from bottom of my heart.💜
from bangladesh
Smile while closing session is awesome mam❤❤❤😊😊😊
Thank you so much this video cleared my all confusions ❤️❤️
Ma'am can you start some coding from geeks for geeks, it will be a great help if you start placement series, from geeks for geeks, Hacker and leet codes.
Aaj hi padna ka mood aya
Aaj hi a topic samajhna tha
Aur
Aaj hi aapne upload kardiya
😂acha tha na phir tu
from Ensah Morocco best teacher😍😍😍😍
Ma'am you said associativity of post increment and decrement is left to right and associativity of pre increment and decrement is right to left in your previous video of associativity video
Exactly
Thanku mam.... For explaining things... So simply.. 😊✨💐.....
#include
int main()
{
int a[ ]={3, 2, 67, 0, 56};
int *p=&a[0];
printf("%d", ++*p);
return 0;
}
out puts 4
Would like to share this at 1st p prints 3 as the aesterick marks it at the base index Then increments the value which is 3 by 1 to out put 4 at the console .
👏
n a standard C environment, the expressions ++*p and *p++ are distinct and have different behaviors.
++*p is the pre-increment operator applied to the value pointed to by p. It increments the value before it is used in the expression. So if p points to 3, then ++*p increments 3 to 4, and 4 is the result used in any further expression.
*p++ is the dereference operator applied to the value pointed to by p, followed by the post-increment operator applied to the pointer p itself. It dereferences the value (fetches the value 3 in this case) and then increments the pointer to point to the next element in the array after accessing the value. The result used in the expression is the original value before the pointer was incremented.
thanks for the lecture im learning a lot thanks to you I have just a little concern on this topic on incrementation and deference that can happen , I don't know why on your computer is giving you this strange results.
In a standard C environment, the expressions ++*p and *p++ are distinct and have different behaviors.
++*p is the pre-increment operator applied to the value pointed to by p. It increments the value before it is used in the expression. So if p points to 3, then ++*p increments 3 to 4, and 4 is the result used in any further expression.
*p++ is the dereference operator applied to the value pointed to by p, followed by the post-increment operator applied to the pointer p itself. It dereferences the value (fetches the value 3 in this case) and then increments the pointer to point to the next element in the array after accessing the value. The result used in the expression is the original value before the pointer was incremented.
yes mam please make questions after completing the lecture of C .
Mam
please do lecture on Object oriented Progming in c++
My favorite computer language is c++
@@sujathanarayana2286 Do you know this language very well?
The output of 14:13 will be garbage value, 3, 2
Thank you so much for the explanations, before watching your videos to this point, I really felt dumb.
Isn't it 2,3,garbage value?
@@33_amit okay
Ok but why in the case printf("%d %d",*p++, *p++); it displays result on the other way ?
yeah I know but because 0 WAS the garbage value for me for instance@@33_amit
your each video is very clear mam
Thanks a lot Mam for this lecture!!!
Garage,3,2
Yes
Mam please make a video on String in C programming.
Best teacher ❤️
Please please make videos on DSA placement specific questions??
Me jee aspirant hu mujhe ye subject Ghanta nhi pata par aap bohot cute ho
output is
some random number
3
2
Mam pls make vedios on dynamic memory allocation
hello mam, the last one is showing only 1 1 1. don`t get, please help.
Thankyou Jenny!! You explained it very well!!
ma'am but post increment operator ki associativity to left to right hena ??
Mam has confused at many points
Yes
my compiler is following associativity from left to right. I don't know why it is so
be part of subject madam attracted my attention more 🥰
Ma'am.When will the classes of C++ start
Thank you so much mam!!❤️❤️
Spreading knowledge is very usefull to all of us thanku sis
thank you my dear mem 🙏, 🙏🙏🙏🙏🙏🙏🙏😍
Best lecture your lovely student ❤️❤️❤️
Hi
char ch =x;
char *pch=&ch;
printf(" uppercase is %c",*pch-32);
output = X;
according to what you said *pch should return x's address right ?
or increment/decrement different from adding integers ??
please clarify doubt ..........
bro in the print statement u use that indirectionor dereference operator so only its given captial X i think so but i'm not sure about my answer are correct
Great explanation 🥳
printf("%d",*p++); -> output is 3 , 2 it is will correct ouput maam
Thanku jenny
❤❤❤❤❤❤❤❤❤❤❤❤❤
Pointer and arthematics are different
Thank you mam your lecture is Very Lovely 😍🌹🌹
Is it possible to make GUI, using C library entirely?
answer mila to mujhe bhi batana
if you get the answer let me know
Make a video on how multidimensional array acts as a pointer when used as formal argument for a function
Thanks for your efforts mam
Nyc sinha
Kya mujhe koi samjhayega mam ne right to left q evaluate kiye postfix hone ke baojud bhi postfix ka toh left to right hota hai at qno 9:09
Please you can tell the c++ course also naa mam🙏
Me too.
*p++,*p++ for post increment associativity is left to right s
we should go from left to right why mam said it is from right to left .
in my compiler it is right to left
14.3 output- any garbage value,3,2...
I wrote this program in visual studio
#include
#include
int main()
{
int a[] = { 1,2,3,4,5 };
int* p;
p = a;
//p = p + 4;
printf("%d
", *p);
printf("%d
%d
%d
", *++p, *++p, *++p);
return 0;
}
Output is:
1
4
4
4
It looks to me first it is incrementing the value p 3 times and the start printing.
----------------------------
Same observation in pre-decrementing.
---------------------------
Anything has been changed ?
for post decrement/increment associativity is left to right, but valuating from right to left . anyone know why
because precedence of post increment/decrement higher than the operator *( asterisk)
@@Rishabh11_12 so we should move from left to right but why mam said right to left
Yes I too have a doubt @Rishabh is saying correct
Ma'am
make a video Job's on without coding and programming.
It is right, yha it's taken
Thankyou Mam
It is coding process right way
17:41 mam i am getting output as 3 2 why so mam??
Well said madam zi
Good lecture but unnecessary lagging,like there is 7 lecture +2 lecture for pointers ,null void pointers with average video length of 20 min😢
So what's the problem ?
Is it possible to use the increment and decrement operators in for loop to print the array ?
yes i try
Could you please tell me the gate syllabus for csbs please
10:58 ma'am its undefined behavior wright ??
Mam lec 72 is missing from play list
🔥🔥🔥
finally I came here for thinking about my crush
Padhai likhai karo IAS bano🤣🤣
@@technicalspider2547 yes bro but I really want her
@jayanth rao why
@@Btech_holder because
This is not any crush or romance channel
Right, madam zi
Thank you ❤,
brilliant explanation
output is
garbage value, 3 , 2
Crt
Mam jac 12th class computer science with C plus plus ka mcq questions and answers krwayiye plz mam
i am coplitely understand look your lecture
Mam can you please make video's in hindi
Body subject is right
👍👍
in c ++ pointer how creat in programming...
❤️❤️👍
Maan big fan of you mam
You don't take a bractet in printf statement
Mam is so beautiful
mam, i am getting like 4011434 something same code which I have written while *--p
The answer is
garbage value, 3 , 2
end of the program!
Maam printf("%d %d",*p++, *p++); why it reads from right to left in this line ? Even chatGPT not able to give me the answer :(((
It is because of the property precedence. I two things have same Associtivity then prefedence comes into picture
🥰