Skip to player
Skip to main content
Skip to footer
Search
Connect
Watch fullscreen
Like
Bookmark
Share
Add to Playlist
Report
1. Skeleton of C++ Program
Technical Education
Follow
7/22/2024
1. Skeleton of C++ Program
Category
📚
Learning
Transcript
Display full video transcript
00:00
In the previous section, we have already learned how to download and install the compiler and
00:06
the IDE required for developing C++ program.
00:10
Hope you are ready with the setup.
00:11
If you are not ready, I suggest you to go back to the previous section and watch the
00:16
videos and get the environment ready on your PC.
00:21
In this video, I am going to show you the skeleton or the basic programs of C++.
00:27
In the following video, you will find a demo how to start a new project and how to develop
00:31
the first program.
00:34
First of all, let us start with the skeleton of a C++ program.
00:39
This is a skeleton already I have kept it ready here.
00:43
You have to start a new project.
00:44
Let us say the project name is first and the program file is first.cpp.
00:49
You have to start this one.
00:52
Inside that this is what you have to return.
00:54
Every C++ program basically looks like this.
00:58
Let us understand what are these elements.
01:00
I will start from this point.
01:02
See this is the starting point of a C++ program main function.
01:07
This is main and the round brackets are there so this is a function.
01:11
This main function is the starting point of a C++ program.
01:15
Then what is this int?
01:17
This is called as return type of a function.
01:20
We will be learning about the return types and all afterwards but right now as a formality
01:25
you have to write it always and when you have return int there at this place then you have
01:30
to write return 0 at the end of the main function.
01:36
This is the body of main function that is the opening flower bracket and closing flower
01:41
bracket.
01:42
Now what all you have to write on?
01:44
You have to write it here inside the body of main function.
01:50
Then what does it mean by this hash include?
01:52
I will explain it.
01:54
First of all I will write something here inside the main function and show you.
01:59
Here as a first program I want to give a welcome message so I will write hello world.
02:05
I want this program to print on the screen hello world when I run the program.
02:12
How to print something on the screen?
02:14
For printing anything on the monitor that is on the screen from your C++ program there
02:20
is a built in object available in C++ that is Cout.
02:26
C means console out that is console out.
02:32
Monitor is treated as a console that is output console then there is something that is keyboard
02:39
that is useful for taking input.
02:42
This is input console.
02:45
It means for that there is Cin, Cout for monitor console out, Cin that is console in for keyboard
02:55
that is taking any input from the keyboard.
02:58
Let us use this Cout and print something on the monitor.
03:02
As I said we will be printing hello world.
03:05
We have to use this two angular brackets this is called as insertion operator.
03:13
We have to use this one for printing anything then here inside double quotes I will say
03:20
hello world.
03:22
Whatever the message that you have to print you have to give it in double quotes.
03:27
This is a string or a message this is given to Cout so it will be printed on the monitor.
03:35
When you run the program hello world will appear here.
03:43
Cout is an object used for printing anything on the monitor.
03:48
If you see this double less than symbol, two less than symbols those are.
03:53
On the keyboard you will find less than symbol hit it for two times.
03:57
That is acting as an insertion operator.
04:00
If you feel it, it looks like as if I am inserting this one inside Cout.
04:05
Once I insert it, it will appear on a monitor.
04:09
It gives the feeling that we are inserting something that is why it is called as insertion
04:13
operator.
04:14
This is how we can print.
04:17
Where this Cout came from?
04:19
We know that for every C++ program we should write down int main flower bracket close and
04:26
return.
04:27
We are writing here where this Cout came from.
04:30
The Cout object as well as Cin object these are present inside this iostream header file.
04:39
Actually this is a library.
04:42
Library will contain the collection of built in objects or functions that a programmer
04:48
can use and easily write the program.
04:51
This is provided by C++ compiler when you install the compiler you will get the libraries.
04:57
There are many libraries we will learn about them slowly.
05:00
Whatever your requirement is depending on that you can include the library in your program.
05:05
Everything from the library will be attached in your program and you can use it.
05:10
Cout is present in this library iostream library.
05:14
For including that one we include bytes name or bytes header file.
05:20
In some compilers even you have to write on iostream.h.
05:25
If this doesn't work in your compiler then you write iostream.h or else just iostream.
05:33
Now I will remove these things and I will explain few more things about this one.
05:38
This Cout as it is present there we cannot use it directly we have to write down namespace.
05:45
I have to write std double colon this symbol you will find on the keyboard you hit it for
05:51
two times so this is scope resolution colon and colon that is double colon this is called
05:56
as scope resolution.
05:58
So the correct method is write down std scope resolution then cout and whatever you want
06:04
to give.
06:05
This is how we use that cout object.
06:08
Now this is a perfect program.
06:10
If you run it you will get hello world on the screen.
06:15
Now one more thing if you are writing a very lengthy program or bigger program and you
06:19
have to use cout many times then instead of writing it like this there is another way
06:24
of doing this using that cout as well as cin object.
06:29
The other method is here we can write using namespace and this namespace name.
06:40
So when we say that we are using this namespace so we don't have to say this one we can directly
06:46
write cout.
06:47
It means that we are using that namespace means whatever is there inside that namespace
06:52
we are using it.
06:53
Now what does it mean by namespace?
06:55
See all the built in things available in this header file that is library are grouped under
07:00
one name that is std.
07:03
So for using that we have to say using namespace.
07:07
Now more about namespace we will learn it in this course you will find a topic there
07:12
is a video available it is a separate topic.
07:14
So everything about the namespace is discussed there.
07:18
Now writing std here is better than saying that we are using namespace because we are
07:25
not using everything from the namespace we want just cout so writing std colon and cout
07:30
is better but it is easy for the beginners to just write cout so I may be using cout
07:36
many times.
07:37
On the top I will be writing using namespace and here I will write cout just cout.
07:44
So that's all is the first program.
07:46
Let us quickly look at the things that we have learned.
07:49
See we have learned that every C program will have a main function main function should
07:52
return integer and as it is returning so here we should write down return 0 then inside
07:58
this flower brackets that is body whatever you want you can write down here.
08:02
So in my program I am just displaying it so for that cout is an object that is already
08:06
available I am using it for printing something on the screen.
08:10
This cout is present in the header file so I should include the header file and this
08:15
header file is having this namespace so I should also use that namespace just including
08:20
the header file is not sufficient you have to use that namespace inside that one.
08:24
If you don't want to use it then you can write down std scope resolution here.
08:29
The next video I will show you some simple programs of C++.
Recommended
4:56
|
Up next
Dev C++ First Program in Urdu & Hindi, Start Coding -Saif
Boom Boom Shikari
1/24/2018
13:54
دليل المبتدئين الشامل: قواعد كتابة أكواد C++ والجمل البرمجية الأساسية | C++ Basics: Comprehensive Guide to Syntax & Statements
InfoFlowDev
7/27/2025
7:40
1. How to program in C# - BASICS - Beginner Tutorial
Code C##
12/5/2016
8:12
उरण प्रकरणात लव जिहादचा आरोप करणाऱ्या नेत्यांना शर्मिला राज ठाकरेंनी सुनावलं...
Technical Education
7/30/2024
4:01
CM Yogi on Love Jihad: लव जिहाद पर उम्रकैद | CM Yogi Big Decision | Religion change | वनइंडिया हिंदी
Technical Education
7/30/2024
3:15
Bhopal News: भोपाल के लिए पहली खुशखबरी, कोलार डैम के दो गेट खुले, लगातार जारी है झमाझम बारिश
Technical Education
7/30/2024
4:18
#usa #america #canada #uk #love #newyork #instagram #california #travel #instagood #fashion #photography #australia #india #germany #trump #london #follow #dubai #france #europe #like #art #miami #florida #a #italy #unitedstates #nyc #music
Technical Education
7/30/2024
1:48
1. Install Compiler
Technical Education
7/22/2024
16:34
2. How Computers Works
Technical Education
7/22/2024
1:08
1. Fundamentals
Technical Education
7/22/2024
3:03
1. Instructors Note
Technical Education
7/22/2024
5:47
3. Demo - First Program
Technical Education
7/22/2024
5:22
3. Setup Dev-C++ and Settings
Technical Education
7/22/2024
6:42
3. Introduction to Number Systems
Technical Education
7/22/2024
6:10
4. Setup Visual Studio
Technical Education
7/22/2024
6:16
2. Setup CodeBlocks and Settings
Technical Education
7/22/2024
5:00
How_Can_ISO9001_Help_Your_Business_Succeed
Technical Education
7/18/2024
1:00
Section_4_Introduction
Technical Education
7/18/2024
3:30
What_Is_A_QMS
Technical Education
7/18/2024
5:40
Clause_4
Technical Education
7/18/2024
5:12
Management_Responsibility
Technical Education
7/18/2024
8:55
Continual_Improvement
Technical Education
7/18/2024
7:10
The_PDCA_Cycle
Technical Education
7/18/2024
2:45
Quality_Manuel_Template
Technical Education
7/18/2024
9:29
Tips_and_Tricks
Technical Education
7/18/2024