Interview Question | C Programming Language

Sdílet
Vložit
  • čas přidán 7. 09. 2024

Komentáře • 1K

  • @yashpreetsinghkalsi5380
    @yashpreetsinghkalsi5380 Před 11 měsíci +3645

    same question was asked in my internship interview

    • @Socialmedia......Addiction
      @Socialmedia......Addiction Před 11 měsíci +66

      Toh answer kya Diya tha?

    • @rajshiromani727
      @rajshiromani727 Před 11 měsíci +107

      Tb bhi ans ni pta bhai??
      Ans is Hello5😅

    • @TarunSharma-eq3fg
      @TarunSharma-eq3fg Před 11 měsíci +25

      @@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 😅)

    • @gulhusain6015
      @gulhusain6015 Před 11 měsíci +30

      ​​@@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

    • @TarunSharma-eq3fg
      @TarunSharma-eq3fg Před 11 měsíci +5

      @@gulhusain6015 oh thanks 😅

  • @shubh_m1
    @shubh_m1 Před 11 měsíci +1512

    Please keep posting videos like this.

    • @Sam_sh02
      @Sam_sh02 Před 11 měsíci +4

      ​@@nishagwaliya476???

  • @thesniperxd5302
    @thesniperxd5302 Před 3 měsíci +100

    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 ❤

  • @rudragajjar454
    @rudragajjar454 Před 11 měsíci +829

    output is: 'Hello 5' since the printf("Hello"); statement will also be executed

    • @rajshaikh3448
      @rajshaikh3448 Před 11 měsíci +32

      Bhai bilkul sahi bola

    • @sky333suraj
      @sky333suraj Před 11 měsíci +74

      The format specifier %d just prints integer.

    • @rudragajjar454
      @rudragajjar454 Před 11 měsíci +48

      @@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

    • @mohammedarifofficial
      @mohammedarifofficial Před 10 měsíci +17

      I think "hello 5" is the real answer;

    • @santoshkumargupta6339
      @santoshkumargupta6339 Před 9 měsíci

      Perfect bro

  • @rounakverma8115
    @rounakverma8115 Před 8 měsíci +70

    This is most common question among all the interviewers, thanku mammm!

  • @anshu2005
    @anshu2005 Před 11 měsíci +30

    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.

  • @harshahm0130
    @harshahm0130 Před 11 měsíci +112

    Actually Output is Hello5 because basically printf primarily does its work of printing the text and count the number characters which stores in x

    • @ratnajaiswal169
      @ratnajaiswal169 Před 11 měsíci +1

      Is there any way to print only number of characters not the original word in printf ??

    • @K15H4N
      @K15H4N Před 11 měsíci +2

      ​@@ratnajaiswal169space Instead of word.

    • @iTsRko_
      @iTsRko_ Před 6 měsíci +1

      Hello 5

    • @kratika83186
      @kratika83186 Před 2 měsíci

      @@ratnajaiswal169 yes indeed , use
      int x = strlen(“Hello”);
      and define library function
      #include

    • @wildyoutuber2615
      @wildyoutuber2615 Před 2 měsíci +1

      what is x not output

  • @sohamghosh533
    @sohamghosh533 Před 11 měsíci +640

    Output is "Hello5" not just 5 as it will also execute printf("Hello")

  • @pavitrakumarsahu2522
    @pavitrakumarsahu2522 Před 11 měsíci +15

    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.

  • @peak_911
    @peak_911 Před 11 měsíci +55

    I think this concept of interview qs type videos is very helpful, can you guys make a playlist for interview qs shorts?

  • @rishabshukla5077
    @rishabshukla5077 Před 11 měsíci +59

    We need more like this

  • @divine3832
    @divine3832 Před 11 měsíci +3

    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

    • @mn-t8u
      @mn-t8u Před 11 měsíci

      Is shows error , bro int x sirf integer leta hai to int x ko ham print hello ko kaise print kr skte

  • @technoprogramming4753
    @technoprogramming4753 Před 3 měsíci +3

    5 because printed function returns lengthy of a string

  • @Memer09157
    @Memer09157 Před 8 měsíci +2

    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

  • @introvertsenpai9968
    @introvertsenpai9968 Před 11 měsíci +8

    Thank you ma'am, I thought I was good at C language but this was something new for me 😊

  • @MaaRiGAMINGOP
    @MaaRiGAMINGOP Před 11 měsíci +2

    First line will give output Hello and assign value to x then second line print 5 combine will be Hello5

  • @sanatani-aatma
    @sanatani-aatma Před 8 měsíci +326

    Samjh to nahi aaya but sunke acha laga 😂😂😂

    • @bavyagastya2149
      @bavyagastya2149 Před 7 měsíci +7

      No. Of character bhai printf function me Hello likha hai there is 5 characters in Hello to screen par output 5 aayega simple

    • @SwingMotor
      @SwingMotor Před 6 měsíci +7

      Sanatani ko kab se samaz nhi aa rha ha 😅😅

    • @anuj-13
      @anuj-13 Před 6 měsíci +1

      😂😊

    • @AlhamdulillahW
      @AlhamdulillahW Před 5 měsíci +3

      ​@@SwingMotor 😂😂😂

    • @Shrutiyadav_108
      @Shrutiyadav_108 Před 4 měsíci +11

      ​@@SwingMotor Jo samjha rahi hai vah bhi sanatani hi hai

  • @anycontent4u457
    @anycontent4u457 Před měsícem

    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

  • @NayanW5
    @NayanW5 Před 11 měsíci +8

    Wow! Each day you learn something new...

  • @ayushthaware344
    @ayushthaware344 Před 11 měsíci +1

    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

  • @kunalmahurkar271il
    @kunalmahurkar271il Před 11 měsíci +40

    Didi @ApnaCollegeOfficial Correct answer is **Hello 5**
    Because of %d is used length of *hello* also print.

  • @superbikelover01
    @superbikelover01 Před 11 měsíci +9

    In this question answer is "HELLO 5" BECAUSE value of int x is how many alphabet in Hello and hello is also print

    • @shikharpahade3959
      @shikharpahade3959 Před 11 měsíci

      Data type is int , so only integer value will be printed

    • @kanhagarg1525
      @kanhagarg1525 Před 11 měsíci

      Hello5 without space

    • @DarkMysterioGaming
      @DarkMysterioGaming Před 11 měsíci

      ​@@shikharpahade3959no bro

    • @superbikelover01
      @superbikelover01 Před 11 měsíci +1

      @@kanhagarg1525 yes but I mention in this comments for understanding "HELLO5" THIS IS REAL OUTPUT

    • @shriyanshu_9k
      @shriyanshu_9k Před 11 měsíci

      ​@@shikharpahade3959bhai practical krke check krle....hello5 print ho rha h

  • @jaykant0007
    @jaykant0007 Před 9 dny

    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.

  • @Reactiverahul
    @Reactiverahul Před 3 měsíci +19

    In python
    Output
    Hello
    None

  • @jarvis9263
    @jarvis9263 Před 7 měsíci +4

    #include
    int main() {
    // Write C code here
    int x = printf("Hello
    ");
    printf("%d
    ",x);
    return 0;
    }
    output --->
    Hello
    6

  • @killxsad
    @killxsad Před 11 měsíci +1

    for the people in the comments saying it will print hello5, the question in the video is: "what is x?", which mean what comes in place of x and the answer is '5'.
    The complete output will be 'Hello5'.

  • @akashsonar6332
    @akashsonar6332 Před 11 měsíci +18

    These small things make big difference in interview..

  • @siddheshnarwade3647
    @siddheshnarwade3647 Před 3 měsíci +5

    As a 12 th std student i m happy to ans the question correctly 😅❤

  • @approgrammingdoor1373
    @approgrammingdoor1373 Před 11 měsíci +3

    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.

  • @meetparmar2107
    @meetparmar2107 Před 11 měsíci +4

    Int x=(printf("hello world") , 18);
    Was asked in iit kgp mid sem exam.

  • @Someone16248
    @Someone16248 Před měsícem

    This is a simple type conversation, the string is a array of character, so it will return the amount of characters it has 😊

  • @sanket7877
    @sanket7877 Před 11 měsíci +4

    didi pls aisehi minute concepts which student ignore during interviews , aur laiye. It will be very helpful

  • @we_four_DAPS
    @we_four_DAPS Před měsícem +1

    Thank you for such type of informative videos🙌🏻❤️💯🤲🏻🤌🏻

  • @sahilmane2601
    @sahilmane2601 Před 10 měsíci +8

    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.

    • @Hloo-z4w
      @Hloo-z4w Před měsícem

      Unhone poocha screen pe kya show hoga...

  • @shubhangiagarkar1708
    @shubhangiagarkar1708 Před 5 měsíci

    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`.

  • @Rama_Siva
    @Rama_Siva Před 11 měsíci +14

    I run this program/code answer aya - hello5.🤔

    • @Rama_Siva
      @Rama_Siva Před 8 měsíci +1

      ​@@vivekdhamande8350 bro character nahi hai eiaha.😂

    • @sarwanray12
      @sarwanray12 Před 8 měsíci

      Ha bhai answer hello5 hi ayega isme x ka value kya print hoga questions ye hai uska answer hai 5

  • @SidsAnalysis
    @SidsAnalysis Před 8 měsíci +1

    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

  • @purveshmahendrakar2110
    @purveshmahendrakar2110 Před 11 měsíci +3

    Make a full length video of understanding this type of concepts

  • @Sattari_01
    @Sattari_01 Před 5 měsíci +1

    Yr kitni piyri h y...AGR issy hi coding sekhi hoti to aj m programer hota😊

  • @ratnajaiswal169
    @ratnajaiswal169 Před 11 měsíci +4

    It prints Hello5...
    Is there any way to print only number of characters not the original word in printf ??

  • @SubhadipBarik-ps5ii
    @SubhadipBarik-ps5ii Před 20 dny

    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 🎉

  • @sahilchopde1450
    @sahilchopde1450 Před 11 měsíci +9

    Answer is " Hello5" not only 5 I also run the program

    • @Tbm4545
      @Tbm4545 Před 11 měsíci +5

      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

    • @luxrayy2041
      @luxrayy2041 Před 9 měsíci

      ​@@Tbm4545yeahhhh

    • @Hbjbsisbehsbsj
      @Hbjbsisbehsbsj Před 4 měsíci

      ​@@Tbm4545 oh

  • @AyoubTahlilHersi
    @AyoubTahlilHersi Před 4 měsíci

    Int is an integer and not a character so only the number 5 will be printed as opposed to being an array of characters [ ] such as hello which is 5 characters. so printf function of hello will be printed and then the number of characters in number "5"

  • @onetofun
    @onetofun Před 11 měsíci +9

    We want more like this...😇✨

  • @mukherjee.p
    @mukherjee.p Před 2 měsíci

    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.

  • @Syed6579
    @Syed6579 Před 11 měsíci +7

    Good question ❤

  • @mansuralikhanpathan4077
    @mansuralikhanpathan4077 Před 11 měsíci +1

    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🙏🏻🙏🏻.

  • @jayrawat3929
    @jayrawat3929 Před 11 měsíci +3

    Meaningful❤

  • @_mukumemories
    @_mukumemories Před 11 dny

    For X, it's 5 but actual output will be "Hello 5"

  • @Aarya_x12
    @Aarya_x12 Před 11 měsíci +15

    OUTPUT (Hello5) aa rha h

    • @ankitkumar-qi3cd
      @ankitkumar-qi3cd Před 6 měsíci

      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

  • @user-he7pc4ty1u
    @user-he7pc4ty1u Před 3 měsíci +1

    Aise hi logic question banate raho mam 😊

  • @AkashSupkar-io9up
    @AkashSupkar-io9up Před 3 měsíci +3

    'X'usiko kahata ha jo hame chor ka chali jati ha 😢😅

  • @CaptainCoder1
    @CaptainCoder1 Před 11 měsíci

    Quite simple problem for those who atleast knows the function signature of printf function it return an integer which is equal to number of characters that it has successfully printed in the console screen.

  • @cheenu2064
    @cheenu2064 Před 11 měsíci +19

    Output will be
    Hello5👍

  • @sagaryadu45
    @sagaryadu45 Před 11 měsíci

    Also it is return blank space and integer value ..

  • @bhavyashah7904
    @bhavyashah7904 Před 11 měsíci +8

    on screen it will display "Hello 5"

  • @LEARN9652
    @LEARN9652 Před 9 měsíci

    Output :Hello5
    Here 5 the number of characters in the string.
    Int type stores integer values.
    %d is used for int ..for printing numbers.

  • @princepexz
    @princepexz Před 11 měsíci +3

    Intresting

  • @PokeBoy-pe8lr
    @PokeBoy-pe8lr Před 6 měsíci

    I am a beginner. If c++ is an extended of c ,then why we use “printf” and “cout” to output a statement.

  • @HarshPatel-sk5fd
    @HarshPatel-sk5fd Před 11 měsíci +6

    output is Hello5

  • @sayuri_20
    @sayuri_20 Před 11 měsíci

    Sis, You really motivate me to study every time I see you. I like You already.

  • @deepakmodi9343
    @deepakmodi9343 Před 11 měsíci

    Mybe answer is 1(if printf is boolean function)
    Or mybe ascii value of each digit
    Or maybe somekind of binary no.
    Edit: 😕

  • @ItsmelaZyCat
    @ItsmelaZyCat Před 8 měsíci

    The answer is not only 5 . It's hello5 as printf("hello"); statement will also execute.

  • @MdRakibulhasan-dq5dh
    @MdRakibulhasan-dq5dh Před 11 měsíci

    yes the x value is 5 .if we get this code output .than we have hello5 output

  • @-MustakimMusa
    @-MustakimMusa Před 6 měsíci +1

    #include
    int main() {
    // Write C code here
    int x= printf("Hello");
    printf("%d", x);
    return 0;
    }

  • @niranjanniru4115
    @niranjanniru4115 Před měsícem

    its simple that you can uderstang that int datatype always return numbers

  • @user-xb3my6zw6r
    @user-xb3my6zw6r Před 2 měsíci

    5?The answer should be Hello only right. Because we aren't giving any other command to print number of characters of the string.

  • @VishalSingh-nn4ne
    @VishalSingh-nn4ne Před 9 měsíci

    %d indicates the integer value thats why 5 will be print

  • @Ankan0_o
    @Ankan0_o Před měsícem

    Output is-
    Hello5
    .. go run this code before starting any argument

  • @suvammagar5287
    @suvammagar5287 Před 3 měsíci +2

    output is "hello5" but X is equals to 5

  • @mrpaulcreations2172
    @mrpaulcreations2172 Před 11 měsíci

    5 , print function returns the length of the printed string

  • @TonyStark-zl3ms
    @TonyStark-zl3ms Před 11 měsíci

    Thank you mam...keep uploading these types of questions...it enhances our knowledge and help us to clear the interview ❤❤😊

  • @rohityadavmudra
    @rohityadavmudra Před 11 měsíci

    IT IS HELPFUL, MAJE MORE SUCH VIDEO'S LIKE THIS ✅♥️🙏

  • @Gear_5five
    @Gear_5five Před měsícem

    The ans is :_5 where (_) is space where printf("_%d"); there was a space there ans is a little bit of space 5

  • @pranavkavishwar1020
    @pranavkavishwar1020 Před 10 měsíci

    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.

  • @tgayush1424
    @tgayush1424 Před 11 měsíci

    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...

  • @subhamdhar8099
    @subhamdhar8099 Před měsícem

    The output will be Hello 5
    If we write printf("Hello
    ")
    The output will be
    Hello
    6

  • @AslamNazeerShaikh
    @AslamNazeerShaikh Před 3 měsíci

    Its programming language specific question.. they questions are good for freshers and not for experienced developers.. 😂 these days people are asking inbuilt function's functionalities outcome

  • @CatchyThreads
    @CatchyThreads Před 9 měsíci

    Sirf 5 print hi hoga q ki variable typ integer declared h then integer form m hi print hoga instead of hello.

  • @pianistmitali8413
    @pianistmitali8413 Před 5 dny +1

    But Didi I'm using Dev C platform on that :-
    Output :- Hello 5
    "Hello 5" is coming, is it right or wrong?

  • @mr.rushold5067
    @mr.rushold5067 Před měsícem +1

    Those who are messed up with c++ due to college teaching....😂

  • @user-on7mj6bd8p
    @user-on7mj6bd8p Před 6 měsíci

    Thank you! I have learned from this video. ❤

  • @Anuragtripathi.19
    @Anuragtripathi.19 Před 4 dny

    This is most base question.in c programming language

  • @callofactiongamingchannel2125
    @callofactiongamingchannel2125 Před měsícem +1

    huh, matlab jitne character ka word hoga ye usse utne number me convert karke value provide karega?

  • @khazeemakanwal7213
    @khazeemakanwal7213 Před 11 měsíci

    We want more this type of questions n this answer
    Thank u didi

  • @rohansapate3890
    @rohansapate3890 Před 11 měsíci +1

    We want more such shorts on C and Java.

  • @muhammad_saad_007
    @muhammad_saad_007 Před 2 měsíci

    Hello5 not just 5 because we are printing the string too

  • @StaticTechnology
    @StaticTechnology Před 7 měsíci

    This is not logic test. This is how much memory you have in your mind.

  • @chiragamerz
    @chiragamerz Před 4 dny

    I don't know c but I know python and Java so I just tried and answered correctly

  • @swanandlaghate5113
    @swanandlaghate5113 Před 11 měsíci

    मॅडम, मैं भी १२-१३ साल से programming languages पढ रहा, उनमे काम कर रहा हू मगर ये बात मुझे आज पता चली, thanks for updating me! मगर interviewer ये सवाल क्यो ऑर किस लिये पूछता ? इसका कंपनी के कोई भी काम मे उपयोग ही नही???

  • @user-is3dw2bh5v
    @user-is3dw2bh5v Před 2 měsíci

    It doesn’t return number of characters but it returns number of bytes. RTFM

  • @user-yy7uw1qx9h
    @user-yy7uw1qx9h Před 10 měsíci

    X is an variable and it's stored the statement that are *hellow world*.

  • @ajaychandra5412
    @ajaychandra5412 Před 4 měsíci

    Kisi bhi programing language me sabse counting 0 se shuru hoti hai isliye 4 print hoga naki 5

  • @AryanJC07
    @AryanJC07 Před 10 měsíci

    Yup its simple thanks for sharing ❤

  • @msa-mirshahzamanabbasi6935

    Maam plz help me out. I knew editing on capcut pro mobile and have edited some stuff. After sometime, mostly clients were rejecting my samples due to lack of editing standard. Therefore, I decided to learn video editing and motion graphics on DavinciResolve. But with that I had joined Governor Sindh IT courses which was being held in Karachi but unfortunately I failed in its test. But after a lot of research I got a knowledge that WEB DEVELOPMENT is more good than VIDEO EDITING. I'm thinking about it since 1 month and I'm totally frustrated and confused that in which field shall I go. Because AI is taking control of programmers. Please help me out in which field shall I go? Now I'll just do what you will say!!!!

  • @khizraaaah.__
    @khizraaaah.__ Před měsícem

    Beauty with brain❤

  • @pkavenger9990
    @pkavenger9990 Před 11 měsíci

    I am python programmer and i have never touched C but as i see int and then i saw d% and gussed that answer will be in digits atleast instead of string.

  • @learningfiru
    @learningfiru Před 6 měsíci +2

    hey mam ; may the R8 answer will be "hello5"

    • @advaitgadekar6771
      @advaitgadekar6771 Před 4 měsíci

      But int return only integer walue how hello can home?

  • @ankitrajarya864
    @ankitrajarya864 Před 5 dny

    Didi ans will be hello 5 ❤❤

  • @abhayrawat1697
    @abhayrawat1697 Před 6 měsíci +1

    Di but hello is a string it must have a null terminated character too...?? Why doesn't it return 6...(Including null terminated character...)..???