Ans is 51 Explanation: First of all we have to remind the fact that printf function not only print the value but also returns the number of character is printed. So in this problem a=7=0111 then a^=5 means a=a^5=7^5=(0111)^(0101)=0010=2 so a=2. Then first of all the inner printf function will execute and as we know a+=3 means a=a+3=2+3=5 then 5 will be printed and it will return 1 as it only prints one character so the outer printf function will look like printf("%d",1). it will again print 1 . so the output will be 51
Thanks so much for fleshing out the answer more! This explanation should have way more likes. Where I struggled most was understanding why CHAR was used and what it would mean (because the code looks like it should only return integers) for the print out once the program was run.
^ is a bitwise Xor operator Perform xor bw 7 & 5 according to truth table Then updated value of a is 2 Now perform 2+3 Then final value of a is 5 1st printf statement ( inner one) will print 5 Then return no of successfully printed character i.e., 1 Then outside printf statement will print 1
The Answer will be 51. Because,2nd printf function will print 5 and then 1st printf function will print 1(cause 1st printf function will read how many chatacter lies in 2nd printf function).
Sir please can you explain why that outer printf function is printing no of character in 2nd printf function.. or say in which lecture in this playlist they said that
Wth just 2 weeks ago I didn't know nothing about c language now I'm happy to know that I know some basics of it. I didn't even know how I learnt this much. Thanks × ♾️
Explanation: First of all we have to remind the fact that printf function not only print the value, it also returns the number of character in print statement. #include int main() { printf("%d",printf("
")); return 0; } Ans is 2 First you try to understand this code and next try the homework problem.
since a = 7 with binary of 0111 and a ^=5 , 5 has binary decimal reprs of 0101. You can also apply the logic of XOR here it works. i.e a ^=5=7^5 .... 0111 and 0101 returns as result of binary 0010 which is 2 inner function executes first printing 5 and returning 1 as it prints only one character. And then the outer function will the returned 1 character resulting to 51.
Ans is 51.. As we solve, the inner printf gives the output '5' . And gives the length of its answer(5) which is '1' to the outer printf instead or origional value 5. Hence The value printed is the result of inner printf = 5 and outer printf =1 On combining it gives = 51.
for the ones asking why a which is an integer was declared as a char , it s simply cuz char is an integer and the smallest one if we count long ... U may be suprised and wondering why well characters are basically numbers, if you check the ASCII table you will understand more , and as u may know char can store up to 127 numbers.
51 is the actual output of the program coz the printf() function not only prints the content inside it but also returns the count of the available contents in it..
Answer will be 51 as the second printf will print 5 as the result got by calculation and after that first printf will count the no of characters which is only one (1). So the final answer will be 51
a = a ^ 5 = 7 ^ 5 = 2; a = a + 3 = 2 + 3 = 5 The inner printf will be executed first whose o/p is 5 and then the outer printf , whose input is printf("%d", a+=3); since any printf returns the number of characters printed succesfully our return value will be 1, therefore o/p is 51.
@@khalilrin-ju3nm because first xor operation prints 5 on screen then it returns number of characters to other printf which in this case is 1,hence the output 51
Answer is 51 first: a^=5; equivalent to a=a^5; // 0111 XOR 0101 = 0010 then the result is 2 second: printf("%d",a+=3); // will print first the the output on screen will be (5) finally the second print will print the number of char returned by the first printf where is 1 char '5'
here the answer is five one because 1st it prints the 1st printf value of a+=3 that is 5 and then 2nd printf funtion returns some value from 1st printf function that no of characters display on screen that is 1 so it is printed so output will be five one
the answer is 51. because here ''a'' is 7 which is (0111), then a^=5 is equals to 2 after processing , so after that a+=3 mean (2+3) which is 5, now the second printf is executed at first so 5 is printed at the first then the first printf prints 1 that is the number of character that is printed successfully.... so the final answer is 51.............
The correct output is 51 Because inner printf prints the output of the expression and outer printf return the number of characters that is successfully prints on the screen And here number of character is 1 So first print 5 then return 1 i. e 51
@@damianmaley4167 The printf function not only print the statement but also return the number of characters so here inner printf print 5 and outer printf return the character 1. Because inside the outer statement there is only one character I. e 5 That's why it returns 1 And final output becomes 51
// First, the inner printf is evaluated // printf("%d", 5) prints 5 and returns the number of characters printed, which is 1 // The outer printf then prints this return value, which is 1
Here, we first do a^5 and then assign it to a. Since a=7=0111, and 5=0101 7 XOR 5 will give 0010=2 So, new a=2 Now, first the second argument of printf gets evaluated, which is another printf argument, according to which a=a+3=2+3=5... And it will print the output as 5 Then second argument becomes "5", and printf displays number of characters of this string, i.e. 1
Comments for myself: char that is equal to 7 (not '7') can act like a normal integer. Therefore shorthand += operation will work here. Answer is 51, the inner printf function will print 5 and return int=1, then the outer printf will print that returned value.
#include int main(){ int a=7; a^=5; printf("%c", printf("%d",a+=3)); } Output: 5 I thought it would be 55 as outer printf also return 5(in ASCII value) Pls how is this ??
Thank you very much sir.... U always simplify the the concepts that we think to be the most difficult... Thank you very much sir... May you be bestowed with a lot of subscribers
I think you need a video or to point people to the existing video that explains the answer. (E.g. The outer printf will return 1 as it only prints one character so the outer printf function will look like printf("%d",1). it will again print 1). Yeah, sort of makes sense but, not really.
My doubt is why it will print 5 as first and then it prints 1 . I understand that there are two printf but why can't it print 15 please do reply I am your subscriber
#include int main() { char a=7; a^=5; printf("%d",printf("%d",a+=3)); return 0; } Ans of first printf [printf("%d",a+=3));] is 5 and the 1 is comes from the %d in second printf [printf("%d"], ....%d in second printf just print the total number of characters in output. what if the out put is not 5 in first printf ,what its 50 then the 1 in the second printf is going to replace by value 2. then the ans is 502. let me know if its right. just tried as shown in the one of the previous videos.
In hw sum, I thought all the options will be wrong answer would be 55 as under printf will return 5 and outside printf will result 55 But when I check the answer by running program is 51
This is two printf statement ok . a^=5 then char value 7 bit value=0111ok .then char value 5is 0101.ok binary of xor value =2(means 0010) ok.second printf is a+=3 ans is 5 then first printf %d means how many character in 2nd printf is only one character(5) okso the final ans is five one 51
#include int main(){ char a =7; // 7 = 0111 a ^= 5; // 5 =0101 /* 0111 0101 ____ 0010 */ printf("%d", printf("%d", a+= 3)); // the nested printf will execute first, which will print out 5 /* the outer printf will execute later, and return 1 since the characters of the first one is 1(nested printf) */ // since there is no space it will be 51 return 0; }
Is there any special purpose in homework questions so that we define a as a char data type...if we define as int data type output will be same then why we did like this???
ANSWER:--- BINARY OF a = 0111; BINARY OF b = 0101; a^=5; which is evaluated as XOR of a = 0111 and b = 0101 ( a= 0111 - b=0101 = 0010) then the value of a = 0010 = 2; then a+=3 , 2+3 = 5; printf(" 1 ", printf("5", a+=3)); then printed first 5 and after 1; O/P: 51
as #include int main() { int a=7; a^=5; printf("%d",printf("%d
",a+=3); return 0; } output was 5 3 and when i used double 's as #include int main() { int a=7; a^=5; printf("%d",printf("%d ",a+=3); return 0; } output was 5 2 help me out
Ans is 51
Explanation: First of all we have to remind the fact that printf function not only print the value but also returns the number of character is printed.
So in this problem a=7=0111
then a^=5 means a=a^5=7^5=(0111)^(0101)=0010=2
so a=2.
Then first of all the inner printf function will execute and as we know a+=3 means a=a+3=2+3=5 then 5 will be printed and it will return 1 as it only prints one character
so the outer printf function will look like printf("%d",1). it will again print 1 .
so the output will be 51
Thanks so much for fleshing out the answer more! This explanation should have way more likes. Where I struggled most was understanding why CHAR was used and what it would mean (because the code looks like it should only return integers) for the print out once the program was run.
@@simonhdenis I have the same problem
Good
omg what a explanation
thanks dude
I am not getting it ... a=4 and b=3
Then a ^ b = 7 so a = 7
Then a ^ b = ( 7 ^ 3 ) So b = 4
Then a ^ b = ( 7 ^ 4 ) so a = 3
OP = 43 ... How cum 51 .
Wow....As u already said in 1st lecture u will fall in love with this subject...It's happening 😄😄😍😍
Yes
yeah
True
a = a ^ 5 = 7 ^ 5 = 2;
a = a + 3 = 2 + 3 = 5;
no of successfully printed characters = 1;
Output:- 51
i am not able to understand can u explain me
^ is a bitwise Xor operator
Perform xor bw 7 & 5 according to truth table
Then updated value of a is 2
Now perform 2+3
Then final value of a is 5
1st printf statement ( inner one) will print 5
Then return no of successfully printed character i.e., 1
Then outside printf statement will print 1
Thanks @nikhil😊
Welcome @sakshi🤗
@@nikhiljain7802 👍
The Answer will be 51. Because,2nd printf function will print 5 and then 1st printf function will print 1(cause 1st printf function will read how many chatacter lies in 2nd printf function).
Perfect Answer
perfect answer
Sir please can you explain why that outer printf function is printing no of character in 2nd printf function.. or say in which lecture in this playlist they said that
@@arvinthathikesav3531 11th lecture
It's 5 not 51
Wth just 2 weeks ago I didn't know nothing about c language now I'm happy to know that I know some basics of it.
I didn't even know how I learnt this much.
Thanks × ♾️
Explanation: First of all we have to remind the fact that printf function not only print the value, it also returns the number of character in print statement.
#include
int main()
{
printf("%d",printf("
"));
return 0;
}
Ans is 2
First you try to understand this code and next try the homework problem.
bro can u explain about this topic , u have any videos about this topic ?
51 bcz a=5 which is written in inside of 2nd print function and ist print function will print the length of 2nd print function's output.
since a = 7 with binary of 0111
and a ^=5 , 5 has binary decimal reprs of 0101.
You can also apply the logic of XOR here it works.
i.e a ^=5=7^5 .... 0111 and 0101 returns as result of binary 0010 which is 2
inner function executes first printing 5 and returning 1 as it prints only one character.
And then the outer function will the returned 1 character resulting to 51.
Please I don't understand how come about the figure 51
Ans is 51..
As we solve, the inner printf gives the output '5' . And gives the length of its answer(5) which is '1' to the outer printf instead or origional value 5.
Hence
The value printed is the result of inner printf = 5 and outer printf =1
On combining it gives = 51.
for the ones asking why a which is an integer was declared as a char , it s simply cuz char is an integer and the smallest one if we count long ... U may be suprised and wondering why well characters are basically numbers, if you check the ASCII table you will understand more , and as u may know char can store up to 127 numbers.
plus for simplicity of bit representation
51. 5- output of inner print . 1- number of charcters in "5"i,e. 1.
The function print 51, 5 (bitwise plus sum) and 1(the return of printf function)
51 is the actual output of the program coz the printf() function not only prints the content inside it but also returns the count of the available contents in it..
Sir... You're explanation is really awesome.... After watching your videos .... I'm very much interested in C language
Answer will be 51 as the second printf will print 5 as the result got by calculation and after that first printf will count the no of characters which is only one (1). So the final answer will be 51
Thank you so much!
Thanks for explanation...
You are doing great work,I don't have more words to specify how good your teaching skills is,...
Keep it up...
a = a ^ 5 = 7 ^ 5 = 2;
a = a + 3 = 2 + 3 = 5
The inner printf will be executed first whose o/p is 5 and then the outer printf , whose input is printf("%d", a+=3); since any printf returns the number of characters printed succesfully our return value will be 1, therefore o/p is 51.
Please I don't understand where the 1 is coming from.
@@judithani2391 it comes from 1st printf(), printf() return the no. of characters printed.
51
Thank you sir for making such a wonderful course freely available for us.
true. but why result is 51?
@@khalilrin-ju3nm output of 2nd print function a=5,ok, then ist print function would print the length of output, ok got it.
@@khalilrin-ju3nm because first xor operation prints 5 on screen then it returns number of characters to other printf which in this case is 1,hence the output 51
@@kwynart6399 thank you bro. Because of u i understood this concept. You gave a very good explanation for that thanks a lot😇😇😇
Answer is 51
first: a^=5; equivalent to a=a^5; // 0111 XOR 0101 = 0010 then the result is 2
second: printf("%d",a+=3); // will print first the the output on screen will be (5)
finally the second print will print the number of char returned by the first printf where is 1 char '5'
In which vedio it is said bruh??..
here the answer is five one because 1st it prints the 1st printf value of a+=3 that is 5 and then 2nd printf funtion returns some value from 1st printf function that no of characters display on screen that is 1 so it is printed so output will be five one
Best tutorial on youtube.I only want say Thank you for these amazing videos.Thanks a lot.
Very very good explanation. A sign of a smart person is making complex things very easy to understand.
Ans is 51 bcz 1 St printf prints the 5 as output and 2nd printf prints the number of digits in the 1 St printf o/ p (1)it prints
Thanks bro
why is ans 51 if output is 5
the answer is 51.
because here ''a'' is 7 which is (0111),
then a^=5 is equals to 2 after processing ,
so after that a+=3 mean (2+3) which is 5,
now the second printf is executed at first so 5 is printed at the first
then the first printf prints 1 that is the number of character that is printed successfully....
so the final answer is 51.............
Then the ans should be 15 na?..
4:21 opt c i.e 51..
heartily thankyouu to the educator and neso academy! you guys r doing incredible work... keep up! hatt's off 🎉❤🙏
The correct output is 51
Because inner printf prints the output of the expression and outer printf return the number of characters that is successfully prints on the screen
And here number of character is 1
So first print 5 then return 1
i. e 51
can you please explain how inner printf gives 5 as output
First u need to calculate xor of 7 and 5
7^5 =(0111) ^(0101)
=(0010)
=2
i.e a=2
a+=3
a=5
@@anishakumari5267 please can you explain how outer printf prints 1?
@@damianmaley4167
The printf function not only print the statement but also return the number of characters so here inner printf print 5 and outer printf return the character 1.
Because inside the outer statement there is only one character I. e 5
That's why it returns 1
And final output becomes 51
@@anishakumari5267 but here is %d. I think %c should be written here
// First, the inner printf is evaluated
// printf("%d", 5) prints 5 and returns the number of characters printed, which is 1
// The outer printf then prints this return value, which is 1
I love neso Academy bcz it's make complex problems to easiest ones 😜
Guys they are providing everything for free and some idots dislikes these types of videos. I think they need mental treatment
Òfficial yes
Right bro
d is correct!
Inner most printf will return 5 as output and outer printf will return counting of inner printf i. e. 1
So output is 15.
a=7^5=2 and a+=3= 5 first print 5 and then printf return length of char which is 1 so ans is 51
Really Recommend this channel !!!!!!
Here, we first do a^5 and then assign it to a. Since a=7=0111, and 5=0101
7 XOR 5 will give 0010=2
So, new a=2
Now, first the second argument of printf gets evaluated, which is another printf argument, according to which a=a+3=2+3=5... And it will print the output as 5
Then second argument becomes "5", and printf displays number of characters of this string, i.e. 1
Comments for myself: char that is equal to 7 (not '7') can act like a normal integer. Therefore shorthand += operation will work here. Answer is 51, the inner printf function will print 5 and return int=1, then the outer printf will print that returned value.
5
the output is 15 because 1st it will print the no. of successful characters=1,then the value of a 5. so ans is 15
Your all lecture make things quiet easy
Good teacher
Thanks you sir
Printf("%d",a+=3);
The output is 5
Printf("%d",Printf("%d",a+=3));
OUTPUT is 1
Thus brings us 51
51 is correct output
a^=5;=2 binary is 0010
Then a+=3 =2+3=5
51... The way of explaining is fantastic !!!
#include
int main(){
int a=7;
a^=5;
printf("%c", printf("%d",a+=3));
}
Output:
5
I thought it would be 55 as outer printf also return 5(in ASCII value)
Pls how is this ??
Thank you very much sir.... U always simplify the the concepts that we think to be the most difficult... Thank you very much sir... May you be bestowed with a lot of subscribers
Ans is 51 because two printf function are used second will print the result and first will print the no. Of characters lies in 2nd printf function
inke liye swarg me alag hi sthan hoga💝🔥🔥
Answer is 51 .if u are curious about how come 1.Try this code
int main()
{
char a=7;
a^=5;
printf("%d",printf("%d
",a+=3));
return 0;
}
answer is
5
6
Cause there are 6 characters in here those are
and a+=3.
In earlier code it only has a+=3 thats the only character and thats why its print 1 after 5.
I think you need a video or to point people to the existing video that explains the answer. (E.g. The outer printf will return 1 as it only prints one character
so the outer printf function will look like printf("%d",1). it will again print 1). Yeah, sort of makes sense but, not really.
in the first practice set .., there is an similar example of this please check that..
ans is 51
Learning much better than my accademy 💖
Ans is 51 ...
Your video really helped me tnx ❤️
thanks for your easy lecture.
Finally I am able to answer the questions without any confusion
i got made with this question, the ans is not 51 that is 5,1
Ans is 51
homework problem is just amazing
51....
Becoz..printf not only prints the content on the screen,it also returns the number of characters that it successfully prints on the screen
What a great Mentor.😍
Your teaching skills are awesome👍
My doubt is why it will print 5 as first and then it prints 1 . I understand that there are two printf but why can't it print 15 please do reply I am your subscriber
Bro plz watch from the first then only you will understand
first the inner printf print and then it will return the number of characters it printed on the console
#include
int main()
{
char a=7;
a^=5;
printf("%d",printf("%d",a+=3));
return 0;
}
Ans of first printf [printf("%d",a+=3));] is 5 and the 1 is comes from the %d in second printf [printf("%d"], ....%d in second printf just print the total number of characters in output. what if the out put is not 5 in first printf ,what its 50 then the 1 in the second printf is going to replace by value 2. then the ans is 502.
let me know if its right. just tried as shown in the one of the previous videos.
thank you for all you doing
In hw sum, I thought all the options will be wrong answer would be 55 as under printf will return 5 and outside printf will result 55 But when I check the answer by running program is 51
Sir in shorthand assignment operator you put "than" instead of "then"
This is two printf statement ok .
a^=5 then char value 7 bit value=0111ok .then char value 5is 0101.ok binary of xor value =2(means 0010) ok.second printf is a+=3 ans is 5 then first printf %d means how many character in 2nd printf is only one character(5) okso the final ans is five one 51
Output :
C) 51
What is the second function like? I know the first function is a = a + 3 and my a is 2. There fore, a=5
Can you please explain this assignment operators with examples so i can understand them clearly
why to define variable as char? output is the same if it was taken as integer.
5 + print one character (5) i.e. 1 so output is 51
i knew the answer without looking comments its 51
realy you're best
#include
int main(){
char a =7; // 7 = 0111
a ^= 5; // 5 =0101
/*
0111
0101
____
0010
*/
printf("%d", printf("%d", a+= 3));
// the nested printf will execute first, which will print out 5
/* the outer printf will execute later, and return 1
since the characters of the first one is 1(nested printf)
*/
// since there is no space it will be 51
return 0;
}
S the output 51 here inner printf gives 5 and outer printf gives how many sets in that outer printf
Is there any special purpose in homework questions so that we define a as a char data type...if we define as int data type output will be same then why we did like this???
51 is the answer 🤗
Can u please explain
I got individual 5 and 1 , how to becomes 51
want to see the person behind all these great lechtures
He is in Instagram...... Jaison joshy.. Go and see him bro
Is the question correct with char? It would print 51 if this code had int
its %d not %c . So its 51
Char can store integers too
Both the casees output will be 51 cause nested printf will give result 5 and outer printf will count the no. Of characters so it is 1 total will be 51
a^=5 bainary is 2 a+=3 tha value is 2+3=5
Why does the 5 have to return 1? Is that a rule or something??
A) 5 ..
Explanation 7^5=2
And a+=3 => a=a+3 => 2+3 =5
I think this is correct if not please correct me
Output : 51
ANSWER:---
BINARY OF a = 0111;
BINARY OF b = 0101;
a^=5; which is evaluated as XOR of a = 0111 and b = 0101 ( a= 0111 - b=0101 = 0010) then the value of a = 0010 = 2;
then a+=3 , 2+3 = 5;
printf(" 1 ", printf("5", a+=3));
then printed first 5 and after 1;
O/P:
51
Yr ek doubt h koi bhi bta do jb hm "char" l rhe h toh sir n %d q lgaaya it should be %c na
I think so???
option c is correct.
I have an doubt if length of 2nd printf is 1 how it prints 51
answer is 5 for a+= and 2 for a^=
a^=2 and a+=5 final output is 5
Ans is 5
Wrong
51
Thank you, Sir
The output of the program is 51
the answer is c=51
Thanks 🙏🏿
Thank u
Mind blowing
its 5 answer because first it perform xor operation then add that number by 3 so it will became 5 in final
is the answer (a)5?
the output is 51;
Output = 51
How we got 51 please explain sir
what if it is given a =+ 1
4:09 answer is 51
output is 51
when i added
as
#include
int main()
{
int a=7;
a^=5;
printf("%d",printf("%d
",a+=3);
return 0;
}
output was 5
3
and when i used double
's
as
#include
int main()
{
int a=7;
a^=5;
printf("%d",printf("%d
",a+=3);
return 0;
}
output was 5
2
help me out
coz new line also treated as a character
here output 5 is one character and new line is one character so output is like that
a=7^5=2
Inner pf a=2+3=5
Out pf 1
51
Ans 51
I used compiler
I couldn't do by hand