Call by Value & Call by Reference in C++ | C++ Tutorials for Beginners #16

Поділитися
Вставка
  • Опубліковано 15 вер 2024
  • Download the best IDE for C, C# and C++: bit.ly/WholeTo...
    ►Source Code & Resources: codewithharry....
    ►This video is a part of my C++ playlist: • C++ Tutorials In Hindi
    ►For Doubt Solving, Brain Storming Sessions & guaranteed replies, join the channel membership here: / @codewithharry
    ►Click here to subscribe - / @codewithharry
    ►Checkout my English channel here: / programmingwithharry
    Best Hindi Videos For Learning Programming:
    ►Learn Python In One Video - • Python Tutorial In Hin...
    ►Python Complete Course In Hindi - • Python Tutorials For A...
    ►C Language Complete Course In Hindi -
    • C Language Tutorials I...
    ►JavaScript Complete Course In Hindi -
    • JavaScript Tutorials I...
    ►Learn JavaScript in One Video - • JavaScript Tutorial
    ►Learn PHP In One Video - • Learn Php In One Video...
    ►Django Complete Course In Hindi -
    • Python Django Tutorial...
    ►Machine Learning Using Python - • Machine Learning Tutor...
    ►Creating & Hosting A Website (Tech Blog) Using Python - • [Hindi] Web Developmen...
    ►Advanced Python Tutorials - • Intermediate/Advanced ...
    ►Object Oriented Programming In Python - • Object Oriented Progra...
    ►Python Data Science and Big Data Tutorials - • Python Data Science an...
    Follow Me On Social Media
    ►Website (created using Flask) - www.codewithhar...
    ►Facebook - / codewithharry
    ►Instagram - / codewithharry
    ►Personal Facebook A/c - / geekyharis
    Twitter - / haris_is_here

КОМЕНТАРІ • 534

  • @nibsprogramming7794
    @nibsprogramming7794 4 роки тому +135

    Analogy of swap function is really commandable( song copy Bluetooth ,song use in Google drive)

  • @ManishSingh-zh8jz
    @ManishSingh-zh8jz 3 роки тому +143

    Rohan Das has separate fan base 😍

  • @noobxgaming3183
    @noobxgaming3183 3 місяці тому +12

    #include
    using namespace std;
    void swap(int &x, int &y) {
    int tem=x;
    x=y;
    y=tem;
    }
    int main(){
    int a=5;
    int b=7;
    cout

    • @hardikbatwal1889
      @hardikbatwal1889 2 місяці тому +1

      Even i got it but i was thinking why he didnt say that ..Many approaches got me confused at the end

    • @subhamsharrma
      @subhamsharrma Місяць тому

      Sale chatgpt use kariya hai 😂

    • @Muhammadzakriya-qy8ex
      @Muhammadzakriya-qy8ex 20 днів тому +1

      so helpful for me thanks

  • @KartikeyaJain
    @KartikeyaJain 3 роки тому +115

    Bro now i feel the actual tough part of coding has begun....i start to feel the difficulty now...guess i will revise all the previous lectures before watching the next one

    • @cs29harshazad22
      @cs29harshazad22 2 роки тому

      @@shubhsharma19 jee rank ?

    • @silverpenetrator739
      @silverpenetrator739 2 роки тому +5

      @@shubhsharma19 bruh

    • @Abhaythakur06x
      @Abhaythakur06x 2 роки тому

      @@shubhsharma19 😶 is it true ?...

    • @gulshansingh7961
      @gulshansingh7961 2 роки тому +5

      @@shubhsharma19 why do you have to interfere and act cool.....can't you just motivate him instead of making fun of him.....

    • @satyaanand9243
      @satyaanand9243 Рік тому

      yes it has begun i will revise all the concepts before lecture 19

  • @harismasoom6634
    @harismasoom6634 3 роки тому +60

    Sir this lecture is very conceptual and you tried your best to teach us in a simple way Hats off to you sir

  • @javacoder8733
    @javacoder8733 3 роки тому +37

    You explained this concept with a superb analogy that any one wouldn't end up finishing this video having doubts in his/her mind regarding pass by value and pass by reference.

  • @AadityaSPatil
    @AadityaSPatil 3 роки тому +92

    I loved the logic we used in this topic, it was probably the most complex one yet. Thank you Harry bhai for explaining it in such detail ♥

    • @mayushi7792
      @mayushi7792 2 роки тому +12

      Aadhe ghante ki vid ke lie almost 1 hour lg gya samjhne me 😂

    • @yashwalke
      @yashwalke Рік тому

      @@mayushi7792 konsi video ye vaali kya plzz batao.....

    • @RaushanKumar-ox7ng
      @RaushanKumar-ox7ng Рік тому

      @@yashwalke 🤣

    • @pavanmadagani7725
      @pavanmadagani7725 Рік тому

      VARANASI SARALA IS A VB, THAT'S WHY SHE SAID EVERYBODY WORKS IN COMPUTER SCIENCE.

  • @paraglondhe4361
    @paraglondhe4361 2 роки тому +47

    It's not the error of the code runner. It is actually a feature to run selected code by the cursor. It may be helpful in python.

  • @PraveenKumar-ev2lr
    @PraveenKumar-ev2lr 3 роки тому +28

    This concept is very much needed in calling functions.
    Thank you sir for clearing all the concepts.🙏🙏🔥🔥🤘🤘😇😇

  • @prathameshyadav2001
    @prathameshyadav2001 3 роки тому +12

    13:10 swapping using c++ reference variables

  • @KunalKumar-yw5wg
    @KunalKumar-yw5wg Рік тому +11

    @CodeWithHarry thanks for your nice videos on c++
    imprtant to mention that swap() itself is a keyword to swap two numbers in c++;
    it swaps two number without even creating a function.

  • @AbhishekKamble-n3j
    @AbhishekKamble-n3j 6 місяців тому +88

    bro sorry but this lecture is very confusing for me

    • @freaky_samosa
      @freaky_samosa 5 місяців тому +4

      Same 😢

    • @naughtyladka
      @naughtyladka 5 місяців тому

      Same yaar 2-3 dusre video dekhkar aaya hu fir kuch kuch smj aaya hai 😢

    • @BakulchandraBhowmik-xv2cr
      @BakulchandraBhowmik-xv2cr 4 місяці тому +2

      You should watch previous videos .

    • @ashsaha5750
      @ashsaha5750 3 місяці тому +4

      Don't worry it will take little time...on my request if you could please watch Call by Value vs Call by Reference in C programming by Harry Bhaiya, it may help you...there the topic is illustrated beautifully...

    • @harshsrivastava7261
      @harshsrivastava7261 3 місяці тому +1

      Everything take time and patience, so go through the process not results

  • @kunalkumar6783
    @kunalkumar6783 2 роки тому +11

    Thank you so much bhaiya for clearing every topic in very concise way. And, i know as simple you are teaching in video is not as simple behind the video, so, i also appreciating your hard work in making such incredible videos. A lot of thanks and best wishes for you Bhaiya.

  • @diptisarkar4849
    @diptisarkar4849 3 роки тому +47

    lmaoo the way he said "valueeeeeeee" at 4:33. love the tutorial tho

  • @SL-jr9uh
    @SL-jr9uh 2 роки тому +14

    This video is a gem if you are having doubts in the concept of pointers

  • @AasmaniKhazana
    @AasmaniKhazana 4 місяці тому +4

    watched more than 6 times and understodd what sir is trying to teach

  • @tejashwinihosur1712
    @tejashwinihosur1712 2 роки тому +5

    Aapke classes dekhne ko maza ata hai bhai.enjoy with learning..😍🤗comedy + teaching...😁fun learning..kabhi bore nahi hota hai ..Thank you so much bhayya.

  • @AshutoshKumar-fu6qe
    @AshutoshKumar-fu6qe 3 роки тому +2

    18:10 , rough.cpp . I really wanted to see what's inside rough.cpp at the beggininh of video. Harry bhai ne meri man ki baat sun li. I will call you "Guruji" from next time. Thank you so much for doing all this for us.

  • @sameersoni3675
    @sameersoni3675 4 роки тому +16

    Call by Value // i.e, the very first function in this video --> int sum(int a, int b)
    Changes made to the formal parameter inside the function have no effect on the actual parameter, Call by Value is used by default.

  • @dravidvaishnav8521
    @dravidvaishnav8521 2 роки тому +9

    point to point explanation with perfect example , covered in minimum time , hats off harry bhai 🔥🔥

  • @parvezsayyed123
    @parvezsayyed123 4 роки тому +8

    you really deserve more likes and views

  • @mohammadmohsinmohammedmohs9717
    @mohammadmohsinmohammedmohs9717 3 роки тому +22

    learning C helped me a lot i completed this playlist in 1 week

    • @P0K0
      @P0K0 3 роки тому +1

      Or main 2 din (approx 14 hours) main 😂

    • @shifuji-7154
      @shifuji-7154 3 роки тому +1

      @@P0K0 gajab meko 4 days lage

    • @anuragtiwari9793
      @anuragtiwari9793 3 роки тому +1

      Same in 9 days

    • @shifuji-7154
      @shifuji-7154 3 роки тому +1

      @@anuragtiwari9793 Op bro

    • @dayanandnimbalkar1706
      @dayanandnimbalkar1706 3 роки тому +5

      @@shifuji-7154 am just the beginners so am learning 2 lecture a day.

  • @shaantyagi2187
    @shaantyagi2187 3 роки тому +15

    Thanks bhaiya it is really helping to brush up the skills and learn new things and the snippets part was really unique .

  • @priyanshpatidar7466
    @priyanshpatidar7466 3 роки тому +384

    elvish bhay ke aage koi bol sakta hai kya??? elviiiiiiis bhaaaaaay

    • @tejasthombare4501
      @tejasthombare4501 3 роки тому +9

      Lovish also😂

    • @hesily7586
      @hesily7586 3 роки тому +9

      I also like to know him..😂

    • @aman.x
      @aman.x 3 роки тому +24

      Gandhi k chacha ka ladka!

    • @kanishakjain2226
      @kanishakjain2226 3 роки тому +40

      Harry bhai ka langotiya yaar.

    • @Ishanx100
      @Ishanx100 3 роки тому +16

      Harry bhai ke chacha hai jo filaal abhi vidhayak mai hai

  • @BlackScreenProductions
    @BlackScreenProductions 2 роки тому +3

    Write a C ++ Program. We have a day-to-day record of USD price in PKR for last 100 weeks. Find the week, which has a highest variation in PKR, while a base price is 160Rs = 1 USD. Also, find which week has the highest average USDprice
    Sir Please Solve The Problem

  • @jeetjain2097
    @jeetjain2097 2 роки тому +1

    big thanks to you harry sir. bhai c++ ka sabse bada confusion dur kar diya aapne.👍

  • @abhaymishra7991
    @abhaymishra7991 2 роки тому +6

    If any thing selected on vs code and if we run program then it will make tempcode file and show error . So be careful before compiling .

  • @aadarshupadhyay761
    @aadarshupadhyay761 3 роки тому +9

    Thank u sir for your effort.
    You videos are the only source for me to lern c++ and java in this lockdown.

    • @WILDfacts2.0
      @WILDfacts2.0 2 роки тому +3

      Have you learn completely from this playlist I don't think this playlist for biegners

    • @GOJOANDSUKUNAFAN
      @GOJOANDSUKUNAFAN 7 місяців тому

      ​@@WILDfacts2.0 iam a beginner I'm in like 45th video of this playlist it's absolutely recommended for you

  • @mianali5664
    @mianali5664 4 роки тому +3

    You are doing nice work bro kindly keep it up

  • @AditiPanwar-ov8xi
    @AditiPanwar-ov8xi 3 місяці тому

    the playlist is really so helpful👏👏, the concept is little bit hard but I would suggest you .... just go through the video twice and read the source code...you will surely understand the concept

  • @AshutoshKumar-fu6qe
    @AshutoshKumar-fu6qe 3 роки тому +5

    17:25 It was some bit hard to understand. But I understood that.

  • @santoshupadhyay2848
    @santoshupadhyay2848 4 роки тому +32

    Sir call by value nahi samjh aaya
    Can you repeat this topic please sir 🙏🏻

    • @sweetyagrawal3751
      @sweetyagrawal3751 3 роки тому +1

      @@bhavyanavyadancechannel8276 oh so call by value is jus using the part that does't worked while swapping is that call by value?
      void swap(int a,int b)
      ..
      int main(){
      swap(x,y);
      }

  • @manishrohila139
    @manishrohila139 2 роки тому +3

    sir if you check source code & resources , you will find that in code snippet 2 result image is wrong as your data mention above result. please check you are brilliant teacher

  • @096harshitgupta6
    @096harshitgupta6 2 роки тому +7

    harry bhaiya ... we can swap the variable using this also ....
    int main(){
    int a,b,x;
    cin>>a>>b;
    x=a;
    a=b;
    b=x;
    cout

  • @Ayan____212
    @Ayan____212 3 роки тому +3

    Thanks for clearing all my doubts and your analogy is amazing

  • @ROSHAN-bf5bj
    @ROSHAN-bf5bj 2 роки тому +1

    Every time I watch a video from harry i first like and then watch. Obviously every video is awesome.

  • @wolfpride9416
    @wolfpride9416 2 роки тому +2

    Very easy and clear explanations ... Thanks a ton

  • @srishtisingh4347
    @srishtisingh4347 4 роки тому +17

    I'm really not able to understand this concept. Sir your videos are very informative and help a lot. But I'm not able to grasp this concept. Is there anyone who can please help.

    • @deepakchauhn1512
      @deepakchauhn1512 3 роки тому

      break the code into steps may be it will help you

    • @wilsondev1652
      @wilsondev1652 3 роки тому +3

      The first thing that he taught that value is not changed is basically the call by value...by which we can't change the actual value ...but then he taught 2 methods of changing it ...and we can change and that change of values of actual parameters by those 2 methods are basically the call by reference topic...

  • @VisionXUpdates
    @VisionXUpdates Місяць тому

    the examples given are commendable

  • @Ninja-cs6mw
    @Ninja-cs6mw Рік тому

    @code with harry bhaiya aapne kafi difficult way mai bataya is topic ko hum direct bhi toh swap kr skte hian 3rd variable ki heip se
    like:-
    // #include
    // using namespace std;
    // int main(){
    // int a,b,c;
    // cout

    • @wasishah84
      @wasishah84 Рік тому +3

      isme function use nahi hue.

  • @syeduzairmohiuddin5514
    @syeduzairmohiuddin5514 2 роки тому +1

    Thanks

  • @kumkumbhagya51
    @kumkumbhagya51 Рік тому +2

    11:19 so in short swap function se bas copy jaa rha hai isliye vaha to change ho jayega par main waale function mai values ka kuch change nhi hoga kyuki vo original hai lekin pointer waale se hum uska address le rhe hai to vaha jo change hoga uske address ki madad se yaha bhi changes ho jayenge
    Am i right?

  • @akshaybankar5228
    @akshaybankar5228 3 роки тому

    void swap(int* a ,int* b){
    int* temp=a;
    a=b;
    b=temp;
    }
    int main(){
    int a=3,b=4;
    swap(a,b);
    cout

  • @ankitkumar012
    @ankitkumar012 6 місяців тому

    Superb series for c++ .............such a nice explanation

  • @Soham_Mhetre
    @Soham_Mhetre 3 місяці тому +5

    Very confusing bro

  • @YADAV_PRINCE
    @YADAV_PRINCE 8 днів тому

    Call by value - original value change nhi hogi. Address sai kuch lena dena nhi bs value ki copy jati hai .
    Call by reference - original value bhi change hogi . Kyunki yaha value nahi jati balki uska address jata hai . Ismai usko value sai kuch lena dena nhi hota . Address mai jo value update hoga woh print krdega

  • @MAMIR47711
    @MAMIR47711 8 місяців тому

    Ge sir your lecture is very interesting and good method of teaching

  • @pulkit8133
    @pulkit8133 7 місяців тому +1

    THANK YOU SIR

  • @techwithpanwar1507
    @techwithpanwar1507 3 роки тому +3

    Legends believe in harry bhai more than the other teacher.

  • @robberz9154
    @robberz9154 8 місяців тому +1

    great explanation harry bhai

  • @sahilprasantachoudhury911
    @sahilprasantachoudhury911 3 роки тому +5

    Self referential note: this video is important

  • @8dmusiccreations64
    @8dmusiccreations64 3 роки тому +1

    7:50 pe pointer ki jgh upr print kraa do values fir to swap ho hi jaengi

  • @AliRaza-h5j5r
    @AliRaza-h5j5r Рік тому

    int main(){
    int x =4, y=5;
    cout

  • @rajanijaiswal333
    @rajanijaiswal333 4 роки тому +3

    thank you bhai

  • @aakashsharma1126
    @aakashsharma1126 4 роки тому +7

    Sir.. i follow your channel. Of c++ , please upload.. frequently.. i request you sir

  • @dilipdelwash3192
    @dilipdelwash3192 4 роки тому +3

    Great Bro Thanks

  • @iitjee3578
    @iitjee3578 Рік тому +1

    ty16😀
    altho bhaiya, still i'm a lil bit confused in this topic cuz i'm learning it for the 1st time. still thnks bhaiya i hope with time i'll get used to it.🙂

  • @sakibrayeen9966
    @sakibrayeen9966 Рік тому

    Bro this concept of pointers and address is really conceptual

  • @Nidhi_jawariya
    @Nidhi_jawariya 4 роки тому +2

    Thank you sir

  • @SantOshS7
    @SantOshS7 4 роки тому +7

    I got confused... i studied and understood different than in this video.....And sound is also not clear.. Please make another video for this topic. BTW you are awesome..Your teaching technique is very good. @codewithharry please make another video in this topic.

  • @jashanpreetsingh6056
    @jashanpreetsingh6056 2 роки тому +1

    good bro great

  • @slip-shape994
    @slip-shape994 3 роки тому +2

    bahut hi sir unorganise way hai aapke illustration ka, you would be great if you will put some efforts in to polish your illustration skill.

    • @monu_7712
      @monu_7712 3 роки тому +1

      I think he knows deeper in programming but he tells about a bit.

    • @slip-shape994
      @slip-shape994 3 роки тому +1

      @@monu_7712 his teaching manner is so unorganised which make things difficult to understand and explanations always be in scattered form.

    • @monu_7712
      @monu_7712 3 роки тому

      What are you doing bro?

  • @cout_OVERTAKER
    @cout_OVERTAKER Рік тому

    8:45 sir here this will not swap values of x and y (actual parameters) and not a and b
    That function will swap the value of a and b (formal parameters)

  • @AnEngineerHuman
    @AnEngineerHuman Рік тому +3

    day-11
    Tuttorial-16 done

  • @prashantsingh-st6sj
    @prashantsingh-st6sj 3 роки тому +1

    thank you so much, Bhai for this kind of teaching

  • @AbhishekSharma-me
    @AbhishekSharma-me 3 роки тому +1

    thankyou bhaiya❤

  • @AbrarAhmed-cv4ur
    @AbrarAhmed-cv4ur Рік тому +1

    10:20 mara demage ki file currupt hoo gi ha 😂😂😂par koe ni dobara dakhna par samjh aa gy.Thanks you

  • @koushik4178
    @koushik4178 Рік тому +1

    Sir apka video mey sob kuch thik hay, but ek problem hay- sob kuch ek sath dekha raha hey, to beginners der thora problem aa raha hay..

  • @chiragagrawal6279
    @chiragagrawal6279 Рік тому

    Turn on autosave in vs code . That might help in problem with code runner

  • @yashviya3698
    @yashviya3698 7 місяців тому +2

    Very hard it is

  • @honestad3558
    @honestad3558 3 роки тому +1

    your videos are awesome but I can't understand this concept ok now should I move I ll watch this video again after completing course

  • @SyedaAbiha-cw2ju
    @SyedaAbiha-cw2ju 4 місяці тому +4

    is lecture ki zra bhi smjh nhi aye

  • @abuhuraira5293
    @abuhuraira5293 2 роки тому +2

    So it means when we use call by value the swap function will not work and when we use call by reference then the swap function will work. right?

  • @nmg4898
    @nmg4898 3 роки тому +1

    bhai please use dynamic inputs(like taking inputs from user)

  • @AjinkyaAJJadhav
    @AjinkyaAJJadhav Рік тому +1

    Harry sir, code likh ke har baar dry run krke dikhao.

  • @kidsfun.220
    @kidsfun.220 Рік тому

    currect boss... your all the videos useful for me...............

  • @anushekmauryanit4614
    @anushekmauryanit4614 2 роки тому +1

    Bro,one small doubt i request u to pls clear,
    When u make swapReferenceVar(int &a,int &b)
    To isme &a ya &b ka data type to integer nahi hai phir bhi ye ek hexadecial type nber ko int data type ke sath kaise accept kar le raha hai.

  • @dipakdutta8783
    @dipakdutta8783 4 роки тому +1

    Thanks Harish bhaiya

  • @sauravmandal5
    @sauravmandal5 2 роки тому

    17:10 I understood but bit tricky , new concept learned here , this was not included in C 15 Hrs tutorial.

  • @itsaryanb9316
    @itsaryanb9316 3 роки тому +15

    Was hard to understand but managed to understand it perfectly by the end of the day😃🥲👍

    • @GOJOANDSUKUNAFAN
      @GOJOANDSUKUNAFAN 7 місяців тому

      Damm i understood in a Hour no cap 🙂🤞

  • @ks-vs2vc
    @ks-vs2vc 3 роки тому +2

    harry bro...smjh nhi aya
    what should i do....i am new to coding.

  • @ShivamQmr
    @ShivamQmr Рік тому

    18:11 sound of realme notification Charge for promotion

  • @JainendraDwivediElectro
    @JainendraDwivediElectro 3 роки тому +2

    Sir ye vid bilkul smkh ni aha.. Apne achanak se swap LA dia jiske bare me koi idea nhi tha Hume.. Plzz make another vid

    • @nithish_raina
      @nithish_raina 3 роки тому

      Do watch some another 2 videos of this type and come back again to his video u will get a clarification.

  • @bukkylens
    @bukkylens 2 роки тому +2

    Bhaiya,How to pass an array by call by reference???

  • @user-hy2nn6nw5n
    @user-hy2nn6nw5n Рік тому +1

    Harry bhai mera to first tym me hi run ho gya . Is that a problem??

  • @UECAshutoshKumar
    @UECAshutoshKumar 2 роки тому +1

    Thank you bhaiya ❤️

  • @ritikabali6466
    @ritikabali6466 3 роки тому +1

    very well explained .

  • @raimubashirkharal8552
    @raimubashirkharal8552 3 роки тому +1

    Great Sir!

  • @sagarbhadre3377
    @sagarbhadre3377 Рік тому

    #include
    using namespace std;
    int sum(int a ,int b);
    int main(){
    int a=4,b=5;
    cout

  • @iSubhoo
    @iSubhoo 3 роки тому +1

    Thank you.

  • @SHIVSAGARKOHAR-z1j
    @SHIVSAGARKOHAR-z1j Рік тому

    thank you harry bhaiya for explaining clearly

  • @bruhhhh187
    @bruhhhh187 2 роки тому +4

    Temp code runner error comes when you select a text and then click the code runner button
    It will only run the selected text
    So unselected any selected code before running the program

  • @Shivam_saxen
    @Shivam_saxen 2 роки тому

    5:30 - swap ho raha hai , without using pointer
    #include
    using namespace std;
    int sum(int a , int b){
    int c = a+b;
    return c;
    }
    int main()
    {
    int x=4,y=5;
    //cout

  • @YahyaKhan1254
    @YahyaKhan1254 3 роки тому +1

    It is more easy in python

  • @jersingh6837
    @jersingh6837 Рік тому

    Thanks harry bhai for these amazing series!

  • @MarufKhan790
    @MarufKhan790 3 роки тому +3

    4:35 😂😂

  • @nafisahmed3607
    @nafisahmed3607 3 роки тому

    Take Love From Bangladesh Harry Bhai ❤️

  • @kunalshahare9041
    @kunalshahare9041 2 роки тому +1

    thanks bhai

  • @NavneetDeshwalJaat
    @NavneetDeshwalJaat 2 роки тому

    at 8:50 if we dont add (&) with X & Y the code will still work.

  • @RohanKumarRA
    @RohanKumarRA 3 роки тому +1

    This topic i didn't understood well,so please make a new video for this