MY SECOND VIDEO ON THIS CHANNEL!
35K views
Feb 6, 2024
"Join us for the excitement of a new chapter with our second video on this channel! In this special installment, we continue our journey, offering more insights, valuable content, and engaging experiences. Whether you're a returning viewer or a new subscriber, this video marks another milestone in our collective exploration. Expect fresh perspectives, interesting topics, and a continued commitment to delivering quality content. Thank you for being part of this journey with us. Tune in, subscribe, and let's continue to learn and grow together in 'My Second Video on This Channel!'"
View Video Transcript
0:00
Hi everyone, welcome to the first lesson on our channel
0:05
Today, we are going to take a look at the basic structure of a C++ program
0:11
So if you want to make that and if you want to know how to write a HelloWorld script using C++ programming language
0:20
and you're a beginner here, so let's get started. Let's don't waste our time and I'm here on my IDE and showing you the basic structure of a C++ program
0:33
So before that, I want to tell you about something. There are some libraries in the backend of C++ programming language or any other language, okay
0:46
And they contain different functions and if you want to use their functions in your entire script, in your entire code
0:56
what you should do, you must include and you must import those libraries into your existing program, into your existing code
1:05
Then you can use their functions, okay? Then you will get the permission, you will get the allowance to use their functions
1:14
So let's get started. How we are going to import those libraries
1:19
First, you should type hsemble and then include. Get it? Now this is called preprocessor, which is used to import the libraries so that we can use their functions
1:35
And then you're going to use, you're going to put lesser than sign
1:40
And then you should write the name of the library that you want to import
1:45
That is istream.h. And then at the end of this line, you should be putting greater than sign
1:53
And you're done. You've done it, man. You've done a great job
1:58
Today you have learned how to import libraries into your script. So this is called hinclude, a preprocessor
2:06
And this entire line is called, you know, we call it header file. Okay
2:15
So that was all how to import a library. Let's go to the next step
2:21
Where I should be writing here using name, okay? Namespace std. That's it
2:32
So what does it mean actually using name std? Why should I write here
2:37
It is because, now let me give you an example. For example, there's a class and it has two students with same names
2:46
So how are we going to differentiate between them? Obviously, we're going to provide some additional information
2:55
Then we can differentiate between them. The same works here. That concept can be applied here in C++ programming language regarding using namespace std
3:07
And then this is called a terminator sign, okay? We'll talk about it later on
3:12
So there are many libraries. They're having the same functions. Their names are same, but they have different functionalities
3:21
So this actually differentiates those functions. So if I want to use functions from iostream.h library, it won't affect any other libraries
3:33
It won't affect any other functions from other libraries. This is how it differentiates them
3:41
This line tells the compiler from where this function came, from which library I've been using that function
3:51
And let's talk about that function. It is cout. cout. coutput. This is a function from the library iostream.h, okay
4:06
And then you're going to use an operator which is called, this is called actually insertion operator
4:15
And that means when you want to display something on your screen, you must be using that because it gives you an output
4:22
So we're going to use operator sign, I mean insertion operator sign, okay
4:32
And then what are you going to do here is to type your code
4:37
Type your message, whatever you want to write here. And exactly the same will be displayed on your computer once you run this program
4:46
For example, I write here, hello world, okay? Because this is hello world program
4:54
Okay, I'm done. I'm almost done. Yeah, I'm done here. And remember, you must enclose them in double cuts
5:04
So whatever I write here, if there are some integers, if there are digits, or there are some characters, it must be shown on your display once you run this script
5:17
And in the end, remember, you're going to use terminator operator. This is a terminator sign
5:24
We use this in the end of a function or in the end of an expression
5:29
But if you go for keywords, if you want to use a keyword in your script, then you should not use this symbol, okay
5:36
But actually, you can say that everywhere you're going to take care of using this terminator, which tells compiler that this function, this expression has ended here
5:47
We're done, okay? And now, if I run this script, it will be shown on my computer exactly the same
5:55
Hello world, okay? And see our function, remember that we use that to display anything that we want on our screen as an output, okay
6:06
So that's it. Now here is something that you should be taking care of
6:12
I want to use something else, okay? Wait, I'm sorry. We're going to do something else, which is really important
6:25
That is int main, okay? This is your main function. Okay, then we're going to put this one, the fiat script, okay
6:39
Here, I'm done, it is easy. Now this is the main body of the script, okay
6:45
The compiler must find the main body in your script. And this is a main function, int main, and then whatever you write here between these curvies, it will be shown and it will be executed
6:58
Actually, the entire script must be executed, but it is the main body and compiler must find the main body of your script
7:06
It is called main function or body of your script, body of your program
7:12
And why should I type here int? Let me tell you. Here I want to type something, return, then zero, then terminator
7:21
Int actually means that int shows integer. So when this body ends, when this function ends, it will return an integer
7:32
And if the script is working fine, it must return zero. It must return an integer, which is zero, when the script successfully ends. Okay
7:43
And if you want to write that here, then you can do it
7:47
How do we do that? Just write here return, and then zero, then use terminator sign
7:54
It shows that your script successfully ends or terminates. And remember to use this function inside the main body as well. Okay
8:05
And there's one another function that you must know, which is get ch. Okay
8:12
Then brackets, and then I'll use terminator. In which library it exists
8:19
That is include. Okay? Include. And then the name of that is, alright, here I made a mistake. Include
8:29
The name of that library is conio.h. conio.h. I'm done with that
8:36
So what is the use of get ch function? Remember, whenever you run the script, the script terminates
8:45
Whenever, when all these functions, all this entire block is executed, the script must end automatically
8:57
But, you know, if you use get ch, then it will not be ended, and it will not be terminated until you press any key
9:07
That is the use of get ch function. Okay? Do you get it
9:12
And now let's talk about something else, comments. Do you know that there are some lines in our script which are called comments
9:21
Comments are actually lines, are lines, a single line or more than a single line, which gives a hint to a reader of your code
9:33
For example, I've written a code about something and somebody else is reviewing my code
9:39
So if that person checks that comment, then he will understand the functionality and the arithmetic algorithm of that script. Okay
9:51
Do you get it? And it never influences your script. It's actually something else
9:59
Okay, let me show you how to write a comment. For example, if you want to write a comment just in a single line, then you should use double slash and then write your comment
10:08
For example, I write here, this code is used to display the given output. Okay
10:22
Given output. I'm done with that. So if anybody opens my script and he just glances at this statement, he will understand that this code, the purpose of this code is just to display something that we have given to the script
10:42
So this is called a comment. And remember, if you want to make a comment, if you want to write a comment more than a single line, then remember how to do that
10:54
Just use single slash, then star. Okay? Let me erase that. Star
11:01
And in the end, you're going to, for example, I've written here, it is our first code. Okay
11:14
So you can see that it is a comment more than a single line, then whatever, what you're going to put here is star and then single slash again
11:25
That is the use of comments. And these are really important when you're writing a script which is consisted on many lines, like thousands of lines
11:38
So that's why these comments are really important. Okay? So that was the end of our video
11:44
No, not the end of our video. Actually, we're going to run this program. Okay
11:49
Here I made a mistake. There's no need to write edge because in the previous versions, we used to write here dot edge, but now it's absolute
12:02
We don't need to write it here. Now let's run the script
12:07
And let me conclude this video. These are called header files. This is your main body
12:14
This is your main body. And actually, these, a getC and a return zero, this is the part of when actually it is called footer
12:22
And this is the main body. It is important to use main function. Okay
12:28
Otherwise, your script will not work. So let's run the script right here
12:33
Just click up right here, execute, and then click compile and run
12:38
And you will see it will appear on your screen. Okay? Now it's executing
12:43
We're going to wait for a while. It's done. You can see that it already appeared on my screen
12:49
Hello world. You get it? You've seen that. We had written here, hello world, and it was appeared on our screen
12:58
So that is our first program, the basic structure of a C++ program
13:05
So I hope you guys enjoyed this lesson. And more lessons are just coming up
13:09
So stay tuned for that. And thanks for watching. I'll see you guys very soon
#C & C++
#Computer Education
#Jobs & Education