@@TarunSharma-eq3fgare wo main function ka return type h int main() function hai n isliye return 0 likh rhe Agar void main() likhte to koi value return nhi krani pdti
It's nice to see that not only the first printf function prints the hello string but it also returns a value to complete the int x = code which the next printf function prints as 5 ❤
Hey I am here to thank universe . The universe helped me in getting a seat in Delhi University. Four rounds had gone and I was with no seat. So I prayed to universe , trusted him , posted letters to him and finally he helped me. I am so thankful to universe.
Didi aapne c language ko bahut achhe se detail se padhaya hai aise aap c plus plus ka padha do n. Hum aap se padhna chahte hai c plus plus. Aapke padhane ka tarika bahut achha hai achhe se samjh me aata hai.
@@sky333suraj yes but the 1st line of code is an assignment statement which are executed from right to left. So the RHS of the assignment which is the command printf("Hello"); is executed first and then it's return value i.e 5 is assigned to variable x
Wow! I am a intermediate C programmer student but literally I also think that the result will be error. As the integer variable can't store the character value. Thank you. Aise hi critical programming ka short video upload karte raho 🎉
This video is very useful to meeru 🥳🥳. I hope to find more questions in it, not only in the C language but also in other programming languages for Interview a🙏🏻🙏🏻.
Let me explain that x: 5 and output : Hello5 Because In c, compiler execute first printf function then it return 5, Hello will print on execution. Then 5 will get assign to x, then last printf function print 5. As there is not any space or new line, it will print as Hello5. Printf function return the no. Of char
Those who are saying it prints Hello5, try running only int x= printf("Hello"); It will give 'Hello' as output, and if you write the complete code, it will print 'Hello5', meaning, 5 is the answer that x is returning
मॅडम, मैं भी १२-१३ साल से programming languages पढ रहा, उनमे काम कर रहा हू मगर ये बात मुझे आज पता चली, thanks for updating me! मगर interviewer ये सवाल क्यो ऑर किस लिये पूछता ? इसका कंपनी के कोई भी काम मे उपयोग ही नही???
Thanks I could learn this for the first time from this video. But it actually prints 6 as printf also counts the null character '\0' . Correct me please if I'm wrong.❤
Some people are saying that the answer is Hello5 but the question is not that what is the output, but it is that what is x and the value of x is 5, not hello5.
Point 1: Output also includes hello and then 5 will be written like Hello5 Point2: printf also takes 'space' as a character If it was written like "Hello w" then printf will count 5+1+1 = 7 . Output is : Hello w7
@@AkankshaSumanofficial The code prints "Hello" and then a number on the next line. The printf("Hello ") function prints "Hello" and returns the number of characters it printed (6, including the newline ). This return value (6) is stored in the variable x. Then, printf("%d ", x) prints the value of x, which is 6.
Hello5 is correct Output The Print statement hello will also be printed, talking about next statement, the length of HELLO that is 5 is printed after that without any space
Bete usne x ka value pucha hai na ki kya print hoga, Wo jo hello print horaha hao wo uper wali print statement ka ans hai aur uske bad x yani ki 5 print horaha hai, aur udhr new line statement nahi use ki hai isliye wo hello5 ek sath print hoarah hai
Certainly! Here's the corrected code that stores the value returned by `printf` in `x` and returns it: ```c #include int main() { int x = printf("hello"); printf("%d", x); return x; } ``` This code prints the length of the string "hello" followed by its actual length, and then returns the value of `x`. So the output will be: ``` hello5 ``` And the return value of the program will be `5`.
Answer ---> Hello 5 Explanation ---> printf() function returns the character count inside the double inverted commas. So first it will print "Hello" followed by no. of characters which is 5.
Jo printable cheeje hongi unka count number print hoga Jaise isme Hello ye sare printable hain Isiliye iska answer 5 aayega However isme \0 null character bhi hai but vo printable nhi hai isiliye vo is count me nhi add hoga
There's nothing to "think" about this. If you know you know lol. You may not be able to just guess the return value out of a random function (random because you typically wouldn't use it like this) right. Typically in systems languages, they usually return the "number of bytes written" from printing or writing functions. So there's that.
same question was asked in my internship interview
Toh answer kya Diya tha?
Tb bhi ans ni pta bhai??
Ans is Hello5😅
@@rajshiromani727 but bhai return 0 ka mtlb to yeh nhi hota ki no. of characters 0 hi print krna (I am new in c language 😅)
@@TarunSharma-eq3fgare wo main function ka return type h
int main() function hai n isliye return 0 likh rhe
Agar void main() likhte to koi value return nhi krani pdti
@@gulhusain6015 oh thanks 😅
This is most common question among all the interviewers, thanku mammm!
Please keep posting videos like this.
@@nishagwaliya476???
It's nice to see that not only the first printf function prints the hello string but it also returns a value to complete the int x = code which the next printf function prints as 5 ❤
whats nice in this?
@@gaddiji maybe that he understood how code works 😂
Hey I am here to thank universe . The universe helped me in getting a seat in Delhi University. Four rounds had gone and I was with no seat. So I prayed to universe , trusted him , posted letters to him and finally he helped me. I am so thankful to universe.
🙄 Wow bro... ❤
I think this concept of interview qs type videos is very helpful, can you guys make a playlist for interview qs shorts?
Thank you ma'am, I thought I was good at C language but this was something new for me 😊
Didi aapne c language ko bahut achhe se detail se padhaya hai aise aap c plus plus ka padha do n.
Hum aap se padhna chahte hai c plus plus. Aapke padhane ka tarika bahut achha hai achhe se samjh me aata hai.
Please c plus plus ka bhi padha do
output is: 'Hello 5' since the printf("Hello"); statement will also be executed
Bhai bilkul sahi bola
The format specifier %d just prints integer.
@@sky333suraj yes but the 1st line of code is an assignment statement which are executed from right to left. So the RHS of the assignment which is the command printf("Hello"); is executed first and then it's return value i.e 5 is assigned to variable x
I think "hello 5" is the real answer;
Perfect bro
Wow! Each day you learn something new...
Actually Output is Hello5 because basically printf primarily does its work of printing the text and count the number characters which stores in x
Is there any way to print only number of characters not the original word in printf ??
@@ratnajaiswal169space Instead of word.
Hello 5
@@ratnajaiswal169 yes indeed , use
int x = strlen(“Hello”);
and define library function
#include
what is x not output
Output is "Hello5" not just 5 as it will also execute printf("Hello")
Yes bro it will excute Hello5
No
me too
Yes hello5
Bhai you are right but she asked what will be printed in place of x not complete o/p
Wow! I am a intermediate C programmer student but literally I also think that the result will be error.
As the integer variable can't store the character value. Thank you.
Aise hi critical programming ka short video upload karte raho 🎉
First line will give output Hello and assign value to x then second line print 5 combine will be Hello5
Sis, You really motivate me to study every time I see you. I like You already.
We need more like this
This video is very useful to meeru 🥳🥳. I hope to find more questions in it, not only in the C language but also in other programming languages for Interview a🙏🏻🙏🏻.
Thank you! I have learned from this video. ❤
Let me explain that x: 5 and output : Hello5
Because In c, compiler execute first printf function then it return 5, Hello will print on execution.
Then 5 will get assign to x, then last printf function print 5.
As there is not any space or new line, it will print as Hello5.
Printf function return the no. Of char
Nice explaination
Yr kitni piyri h y...AGR issy hi coding sekhi hoti to aj m programer hota😊
Those who are saying it prints Hello5, try running only int x= printf("Hello"); It will give 'Hello' as output, and if you write the complete code, it will print 'Hello5', meaning, 5 is the answer that x is returning
Is shows error , bro int x sirf integer leta hai to int x ko ham print hello ko kaise print kr skte
IT IS HELPFUL, MAJE MORE SUCH VIDEO'S LIKE THIS ✅♥️🙏
These small things make big difference in interview..
Aise hi logic question banate raho mam 😊
5 because printed function returns lengthy of a string
Thank you mam...keep uploading these types of questions...it enhances our knowledge and help us to clear the interview ❤❤😊
Didi @ApnaCollegeOfficial Correct answer is **Hello 5**
Because of %d is used length of *hello* also print.
Yss
Without space
But int return only integer walue how hello can home?
Hello5 not Hello 5 no spaces
didi pls aisehi minute concepts which student ignore during interviews , aur laiye. It will be very helpful
Radhe Krishna ji राधे राधे जी
Samjh to nahi aaya but sunke acha laga 😂😂😂
No. Of character bhai printf function me Hello likha hai there is 5 characters in Hello to screen par output 5 aayega simple
Sanatani ko kab se samaz nhi aa rha ha 😅😅
😂😊
@@SwingMotor 😂😂😂
@@SwingMotor Jo samjha rahi hai vah bhi sanatani hi hai
it will print Hello5 as output, cause printf("Hello"); print Hello and printf("Hello"); has 5 characters and 5 is stored in x. So output is Hello5.
Make a full length video of understanding this type of concepts
मॅडम, मैं भी १२-१३ साल से programming languages पढ रहा, उनमे काम कर रहा हू मगर ये बात मुझे आज पता चली, thanks for updating me! मगर interviewer ये सवाल क्यो ऑर किस लिये पूछता ? इसका कंपनी के कोई भी काम मे उपयोग ही नही???
As a 12 th std student i m happy to ans the question correctly 😅❤
I am a beginner. If c++ is an extended of c ,then why we use “printf” and “cout” to output a statement.
Int x=(printf("hello world") , 18);
Was asked in iit kgp mid sem exam.
i guess that comma is of no use there
Same cheez hai, hello world hi print hoga
What is answer??
Thanks I could learn this for the first time from this video. But it actually prints 6 as printf also counts the null character '\0' . Correct me please if I'm wrong.❤
Some people are saying that the answer is Hello5 but the question is not that what is the output, but it is that what is x and the value of x is 5, not hello5.
Unhone poocha screen pe kya show hoga...
Bhai pehla question Sunna karo aacha sa fir Gyan do
Point 1: Output also includes hello and then 5 will be written like Hello5
Point2: printf also takes 'space' as a character
If it was written like "Hello w" then printf will count 5+1+1 = 7 . Output is : Hello w7
#include
int main() {
// Write C code here
int x = printf("Hello
");
printf("%d
",x);
return 0;
}
output --->
Hello
6
correct
Plz explain in words, if possible
@@AkankshaSumanofficial I will explain you in a while . I’m busy right now
@@Exposing.official. oh, thank you so much
@@AkankshaSumanofficial
The code prints "Hello" and then a number on the next line.
The printf("Hello
") function prints "Hello" and returns the number of characters it printed (6, including the newline
).
This return value (6) is stored in the variable x.
Then, printf("%d
", x) prints the value of x, which is 6.
One idea to take is, when we r printing the value of x we also used "%d" which represents an int so the output will be
hello5
5 = charector of str.
Hello5 is correct Output
The Print statement hello will also be printed, talking about next statement, the length of HELLO that is 5 is printed after that without any space
It prints Hello5...
Is there any way to print only number of characters not the original word in printf ??
We want more this type of questions n this answer
Thank u didi
In python
Output
Hello
None
In this question answer is "HELLO 5" BECAUSE value of int x is how many alphabet in Hello and hello is also print
Data type is int , so only integer value will be printed
Hello5 without space
@@shikharpahade3959no bro
@@kanhagarg1525 yes but I mention in this comments for understanding "HELLO5" THIS IS REAL OUTPUT
@@shikharpahade3959bhai practical krke check krle....hello5 print ho rha h
We want more such shorts on C and Java.
We want more like this...😇✨
Yup its simple thanks for sharing ❤
Answer is " Hello5" not only 5 I also run the program
Bete usne x ka value pucha hai na ki kya print hoga,
Wo jo hello print horaha hao wo uper wali print statement ka ans hai aur uske bad x yani ki 5 print horaha hai, aur udhr new line statement nahi use ki hai isliye wo hello5 ek sath print hoarah hai
@@Tbm4545yeahhhh
@@Tbm4545 oh
Plz provide some more shorts on C programming
Meaningful❤
Bring more videos like this, or make a large video like this , this types of questions come in OA , and the prefix and postfix thing also common...
I run this program/code answer aya - hello5.🤔
@@vivekdhamande8350 bro character nahi hai eiaha.😂
Ha bhai answer hello5 hi ayega isme x ka value kya print hoga questions ye hai uska answer hai 5
Phli bar koi sahi jawab mene dia hai apka 😂❤
'X'usiko kahata ha jo hame chor ka chali jati ha 😢😅
Didi ans will be hello 5 ❤❤
Good question ❤
Certainly! Here's the corrected code that stores the value returned by `printf` in `x` and returns it:
```c
#include
int main() {
int x = printf("hello");
printf("%d", x);
return x;
}
```
This code prints the length of the string "hello" followed by its actual length, and then returns the value of `x`. So the output will be:
```
hello5
```
And the return value of the program will be `5`.
Intresting
Answer ---> Hello 5
Explanation ---> printf() function returns the character count inside the double inverted commas. So first it will print "Hello" followed by no. of characters which is 5.
OUTPUT (Hello5) aa rha h
correct bro, qki phle first wala printf apna Hello print krega, phir baad me next wala printf X ki value print krega :-) then output aayega Hello5
Outstanding shradhha ji
on screen it will display "Hello 5"
Also it is return blank space and integer value ..
Output will be
Hello5👍
Yss
Ma'am final output Hello5 ayega aur X ki value 5 ayega
output is Hello5
Hello 5 , space Miss kar diya tune😊😅
For X, it's 5 but actual output will be "Hello 5"
Didi agar char hota to direct Hello print hota na ?
Nhi mam kabhi kabhi editor 6 value bhi return karta hai because null character bhi include kar leta hai.....
This is a simple type conversation, the string is a array of character, so it will return the amount of characters it has 😊
huh, matlab jitne character ka word hoga ye usse utne number me convert karke value provide karega?
Mam post videos in english so that people who don't understand Hindi can also watch your videos
Str_1='Hello'
Str_1=Len()
Ans 5
5?The answer should be Hello only right. Because we aren't giving any other command to print number of characters of the string.
Those who are messed up with c++ due to college teaching....😂
The answer is not only 5 . It's hello5 as printf("hello"); statement will also execute.
We want more videos like this😊
We can change int main to void main, then there will be no need to write any return value
Didi percentage ke base par admission karwana chahiye ya nhi
This is not logic test. This is how much memory you have in your mind.
Bhai mere ko samajh to aa gaya lekin mai program ke liye nahi ruka tha mai to ladki ke akhon me kho gaya tha 😅😅 isliye end tk ruka ❤
4 is the answer.....because hello 0,1,2,3,4
Last me return 0, likhne ke piche kya concept hai c ke is code me?
Good teacher ❤❤
Jo printable cheeje hongi unka count number print hoga
Jaise isme Hello ye sare printable hain Isiliye iska answer 5 aayega
However isme \0 null character bhi hai but vo printable nhi hai isiliye vo is count me nhi add hoga
printf hello ke sath bhi hai x ke sath bhi toh Hello5 aana chahiye?
Beauty with brain❤
Didi koi budget friendly course bta jo badhiya rhe 🙏
There's nothing to "think" about this. If you know you know lol.
You may not be able to just guess the return value out of a random function (random because you typically wouldn't use it like this) right.
Typically in systems languages, they usually return the "number of bytes written" from printing or writing functions. So there's that.
4 mene suna tha programing me counting 0 se start hoti hai ?
Mybe answer is 1(if printf is boolean function)
Or mybe ascii value of each digit
Or maybe somekind of binary no.
Edit: 😕
What if there is integer value eg
int a=5
int x= printf(a);
printf(x);
yes the x value is 5 .if we get this code output .than we have hello5 output
mujhe ye mila tha , answer will be hello 5 (space because _%d) otherwise hello5
But Didi I'm using Dev C platform on that :-
Output :- Hello 5
"Hello 5" is coming, is it right or wrong?
%d indicates the integer value thats why 5 will be print
hey mam ; may the R8 answer will be "hello5"
But int return only integer walue how hello can home?
#include
int main() {
// Write C code here
int x= printf("Hello");
printf("%d", x);
return 0;
}