C++ Tutorials- Void Function

preview_player
Показать описание
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
Рекомендации по теме
Комментарии
Автор

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

ImTryingHarder
Автор

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

wittawinpanta
Автор

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 !

Natan-esms
Автор

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

myname
Автор

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

nintuchoiti
Автор

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

mantronicsenterprises
Автор

this is so helpful after my summer break TYSM!

tramonik
Автор

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

stevetalksmoney
Автор

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

alonzoneal
Автор

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 <iostream>
using namespace std;

int calc(int i) {
return i * i;
}

int main() {
int i = 2;
int result = calc(i);
cout << "The result is: " << result << endl;
return 0;
}

//Second code

#include <iostream>
using namespace std;

void calc(int i) {
return i * i;
}

int main() {
int i = 2;
int result = calc(i);
cout << "The result is: " << result << endl;
return 0;
}

NoTimeWaste
Автор

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

OGOG
Автор

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?

johnsoto
Автор

nice and slow explanation .. thanks man

cloaky
Автор

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

artgamesrandom
Автор

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

icemotion
Автор

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.

LiarsPendulum
Автор

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

Life-style-
Автор

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

ernestogarcia
Автор

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 :')

nashh
Автор

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

dotastrategy