C++ Tutorials- Void Function

Поделиться
HTML-код
  • Опубликовано: 28 авг 2024
  • In C++, like in many other programming languages, you can group functions into two categories:
    Those that have a return value and those that do not have a return value.
    Functions that do not have a return value are often referred as a void functions. Void functions have the following structure
    graspery.com/c/...

Комментарии • 85

  • @ImTryingHarder
    @ImTryingHarder 5 лет назад +44

    Very well made man, by far the best explanation video i’ve seen for c++ haha a bunch of garbage out there! ❤️

    • @YunusKulyyev
      @YunusKulyyev  5 лет назад +1

      Thanks, I appreciate that!

    • @Hiro-io4cj
      @Hiro-io4cj 3 года назад

      @@YunusKulyyev commenting from year 2020 , and I agree your explanation is good.

    • @Gallardo6669
      @Gallardo6669 2 года назад

      @adam: damn right!!!

  • @wittawinpanta9924
    @wittawinpanta9924 3 года назад +4

    This Channel is definitely one of my top favourite C++ tutorial RUclipsr! Very well made.

  • @myname2597
    @myname2597 3 года назад +5

    i know this is probably late but if youre reading this thank you,ive been scavengering online tutorials/articles for hours trying to understand void they werent working until i came across this and i think i finally grasped it.THANKS A LOT

    • @YunusKulyyev
      @YunusKulyyev  3 года назад +1

      Thank you, I am always happy to hear that it is helpful to others!

  • @Natan-es9ms
    @Natan-es9ms Год назад +1

    I wanted to let you know that thanks to your video I got some informations that I was missing to make my program work, Thank you !

  • @NoTimeWaste1
    @NoTimeWaste1 8 месяцев назад

    So in essence, the int main function pass the values to print function, and the calculation is done in print function and prints out the values, it does not return any value, like the int function did (which passed the value 16 and 32) and the print function prints and not return the 512 value, and thus it prints only the value without returning any value.
    You can implement the following code to check how the void and int works:
    //First code
    #include
    using namespace std;
    int calc(int i) {
    return i * i;
    }
    int main() {
    int i = 2;
    int result = calc(i);
    cout

  • @OGOG1970
    @OGOG1970 2 года назад +1

    Yunus, I'm new to C++ and all programming/coding. Doing homework and was stuck. After re-reading the chapter and professor notes. Still confused. After six damn minutes, you have fixed me on Void Functions. LOL! Should have come to you first. Well played. :)

    • @YunusKulyyev
      @YunusKulyyev  2 года назад

      Hi Eric, love it. Thanks for you rkind words. I am glad that I was able to carry across the idea. Good luck in your programming journey

  • @mantronicsenterprises
    @mantronicsenterprises 4 года назад +9

    Thank you for this video tutorial, it was exactly what I needed.

  • @nintuchoiti7687
    @nintuchoiti7687 2 года назад +2

    Thank you so much for your good explaination. i was really very much struggling with these stuffs. You videos are so clear to understand, just saved me

  • @stevetalksmoney2404
    @stevetalksmoney2404 7 лет назад +7

    You always come up with great stuff. I wish you have more videos

  • @demetriuswright6993
    @demetriuswright6993 4 года назад +3

    you and bucky are my favorite

  • @alonzoneal8090
    @alonzoneal8090 Год назад +1

    Thanks for breaking this down I really get this *Subscribed*

  • @MoherZO
    @MoherZO 4 месяца назад

    Very well explained. Thanks

  • @johnsoto7112
    @johnsoto7112 4 года назад +1

    new to coding here sorry if i come off ignorant, but i dont really understand. Couldnt you get the same thing by just taking out the void?

    • @YunusKulyyev
      @YunusKulyyev  4 года назад +2

      Hi John, yeah absolutely but that is not the point. This example is simple example to show how void function works. When you have a complex code, you don't want to have a giant monolithic block of code. Instead, you want to have your code broken down into many separate function each performing a specific task. That way, managing and debugging your code will be much easier.

  • @artgamesrandom
    @artgamesrandom 5 лет назад +3

    Can you explain how the computer knows which int in the main function associates with which int in the void prototype seeing as their are called diffrent things

    • @YunusKulyyev
      @YunusKulyyev  5 лет назад +4

      It depends on the order that they are sent. For example when I have void print(int x, int y) and I call this function in my main as print(1,5) the first number will be x and the second number will be y

    • @artgamesrandom
      @artgamesrandom 5 лет назад +2

      @@YunusKulyyev ohh that makes sense thank you :)

    • @YunusKulyyev
      @YunusKulyyev  5 лет назад +2

      No problem!

  • @afrobossi8360
    @afrobossi8360 2 года назад

    So why does it execute the void function, even though it's not performed within your main function?

  • @icemotion1925
    @icemotion1925 3 года назад +1

    Oooh. So void is a function that allows us to create a function executing the stuff we included in the {}?

    • @YunusKulyyev
      @YunusKulyyev  3 года назад

      Void is the name of the type that the function{} returns. Since void means nothingness, it returns nothing

  • @LiarsPendulum1
    @LiarsPendulum1 3 года назад +1

    I just started learning C, and the concept of void stopped me cold. I don't understand how you can declare two integers in the main function as rate and hours, but then change them to r and h in the void function and still have the compiler know that int r is the same as int rate and int h is the same as int hour.

    • @YunusKulyyev
      @YunusKulyyev  3 года назад

      It's not the same, void function declares an independent variable called r and assigns the number that was stored in rate. They exist in different memory locations and changing one doesn't affect the other one

  • @user-fk6mw2fc7e
    @user-fk6mw2fc7e 4 года назад +1

    Hey , is the fifth row necessary? Because i think that the 15th one does the same job

    • @YunusKulyyev
      @YunusKulyyev  4 года назад +1

      Hi Xhoni, yes, you can have functions without function prototype, but it has a useful benefits later on

  • @opshorts5001
    @opshorts5001 3 года назад

    Great explanation so far

  • @weslleysantos5467
    @weslleysantos5467 2 года назад +1

    Thx that helped me a lot

  • @Shabarbershop
    @Shabarbershop 2 года назад

    Salam Yunus.Siz bilen nahili yagdayda habarlasyp bolar?C++ barada biraz komeginiz gerekdi?

    • @YunusKulyyev
      @YunusKulyyev  2 года назад +1

      Salam Shohrat, men emailyma yazayyn, graspery@gmail.com

  • @cloaky6973
    @cloaky6973 2 года назад

    nice and slow explanation .. thanks man

  • @nashh2868
    @nashh2868 2 года назад +1

    Hii! Idk if you're still going to answer but may i know that will there be any difference if we put the int main() under the void functions? Andd if the int main () is below.. will the compiler read from the top to bottom or will it read from the int main() first despite being under some other functions?
    A bit confuse on that part but I'll really appreciate if someone could answer it :')

    • @YunusKulyyev
      @YunusKulyyev  2 года назад +3

      Hi! Yeah, you can place int main() below other functions. Compiler will always read int main () first no matter the position

    • @nashh2868
      @nashh2868 2 года назад +2

      @@YunusKulyyev Omg thanks mannn!! I need to submit my assignment tomorrow and you've really help me 🙏🏻🥺

  • @dotastrategy8422
    @dotastrategy8422 3 года назад +1

    bro can you make a video about how void function converting to value returning function? because my teacher ask and I didn't know how thanks bro

  • @ernestogarcia8351
    @ernestogarcia8351 5 лет назад +2

    good job on intro to functions!! I am currently stuck on making a program using void function which asks the user to enter 3 numbers and the program calculates the sum and average. If you or anyone reading knows a good video or can help out please message me!! thank you

    • @YunusKulyyev
      @YunusKulyyev  5 лет назад

      Hey iix, if you have the code, I can check it for you. Or do you have to start from scratch?

  • @KOMEK1999
    @KOMEK1999 3 года назад

    Why did u pit void print in the bottom of int main () ?

  • @kagurakawaii1616
    @kagurakawaii1616 Год назад

    How about a code that asks you to put a name and age using a function and display a outcome

  • @jashwanthsai9605
    @jashwanthsai9605 3 года назад

    I have a question please help me
    Why we should use void and when

  • @Life-style-5
    @Life-style-5 2 года назад

    Hello... thank you bro, you did great job, i like your way of explanation :)

  • @conquest222
    @conquest222 6 лет назад +1

    thanks, helped a lot

  • @anschoudhary1376
    @anschoudhary1376 4 года назад

    why do you need a function protype ?

  • @malou5290
    @malou5290 3 года назад

    leave it to my professor to make it so complicated man!

  • @mobaplayers4534
    @mobaplayers4534 2 года назад +1

    what is return value

    • @YunusKulyyev
      @YunusKulyyev  2 года назад +1

      Void functions have no return value

  • @Lobogrey2
    @Lobogrey2 2 года назад

    Thank you sir 🙏🏽🙏🏽

  • @OldTown_Workshop90
    @OldTown_Workshop90 4 года назад +2

    how u can work in white background xd

    • @YunusKulyyev
      @YunusKulyyev  4 года назад +1

      Lol, there are different schools of thought. A lot of people prefer white background. But I don't code in C++ and on codeblocks much so I didn't care changing the background, but my android studio is on dark theme

    • @OldTown_Workshop90
      @OldTown_Workshop90 4 года назад +2

      @@YunusKulyyev Oh thanks for your answer ^_ , anyway
      that video helped me alot understand void!!

  • @zkkvfvfv5117
    @zkkvfvfv5117 4 года назад

    still what's the point of using a function that won't return anything ?

    • @YunusKulyyev
      @YunusKulyyev  4 года назад

      There is a lot of, like A lot of cases when you don't return anything. If you have a back end server you can use void function to send data and not necessarily return anything. You can display things on the screen without returning and many more

  • @hussianhani4428
    @hussianhani4428 4 года назад

    BIG THANKS MAN! do you know how to use it in more complex code that would help me understand it a lot if you show us!

    • @YunusKulyyev
      @YunusKulyyev  4 года назад

      Hi Hussian, thanks. You can email me at graspery@gmail.com if you have questions

  • @lorenzo4819
    @lorenzo4819 5 лет назад

    Why do we use the void functions? Can't we just print out r*h in the int main function?

    • @YunusKulyyev
      @YunusKulyyev  5 лет назад +1

      Hi LJ, we use functions because what if you want to print r*h 50 times? Well, you don't want to write the same code 50 times. Instead you can just write one function and use it 50 times

    • @suhaip_7031
      @suhaip_7031 4 года назад +1

      @@YunusKulyyev but i can insted use for loop to print 50 times right?

    • @user-fk6mw2fc7e
      @user-fk6mw2fc7e 4 года назад

      You can use for(int i=1 ; i

    • @user-fk6mw2fc7e
      @user-fk6mw2fc7e 4 года назад

      But you can do that with do while😊

  • @sidamkrishna5214
    @sidamkrishna5214 Год назад

    nice man yeah

  • @taseledalpha
    @taseledalpha 5 лет назад +1

    I want your help in making a complex program ...will you pls help me?

    • @YunusKulyyev
      @YunusKulyyev  5 лет назад

      Hey Zainab, what is your project? I will try to help you

    • @taseledalpha
      @taseledalpha 5 лет назад

      @@YunusKulyyev I have to made a website which has 5 parts ...in which a student can register the subjects he wanted to study in this semester along with the credit hours.We are not allowed to use any built in function.

    • @YunusKulyyev
      @YunusKulyyev  5 лет назад

      If you have the detailed assignment, can you email it to graspery@gmail.com
      Also, what language do you have to use. I don't think you will be using C++, most likely javascript

    • @taseledalpha
      @taseledalpha 5 лет назад

      @@YunusKulyyev yeah sure..I will send you complete manual

    • @taseledalpha
      @taseledalpha 5 лет назад

      @@YunusKulyyev it's c++

  • @iulianpop3481
    @iulianpop3481 5 лет назад +2

    TQ bro!!!!

  • @aimanhafiz7601
    @aimanhafiz7601 3 года назад

    thanks dude!

  • @downtownofficial208
    @downtownofficial208 6 лет назад

    Thank u so much

  • @LaimisL
    @LaimisL 4 года назад

    Have you tried linux ?

  • @johanbollemus8444
    @johanbollemus8444 4 года назад

    Thank you. :-)

  • @sudeshpawar6493
    @sudeshpawar6493 3 года назад

    good video but that click sound is soo annoying

    • @YunusKulyyev
      @YunusKulyyev  3 года назад

      :) thanks, I'll keep that in mind

  • @bobbytheferret6809
    @bobbytheferret6809 3 года назад +1

    Hi