First program in C++ | Writing First C++ Program | C++ Tutorial for Beginners

Опубликовано: 06 Октябрь 2024
на канале: Learning Hub
186
10

#c++ #first_c++_program #c++_program
welcome back to the video series of introduction to computer programming let's start our first program in c plus the first step is to use the predefined features which are defined in a header file we use a hash sign the hash sign are called directives and they are processed by a preprocessor a preprocessor is a small computer program which will run before going to the compiler after hash we will use include include this tells the compiler to include a header file it will allow us to use a header file in our program now these brackets in these brackets we are going to give the name of the file in brackets we are going to write iostream it is used for input and output operators we don't have to give any extension of. h here this is a new style of c++ we only have to write hash include in brackets iostream there is no need of any extension the next step is the name space so what is a namespace a namespace is a declarative region that provides a scope to the identifiers such as names of types functions variables and some other are part of name's pace
namespace are used to organize code into logical groups and to prevent name collisions that can occur specially when your code includes multiple libraries we are going to use a standard library which is std
std stands for standard library we are having c in cout which are defined in our name names pace if we are not using the name space whenever we have to use it we have to use a scope of it we will discuss it in upcoming videos now in this video we are using a namespace for that we have to write using namespace std and a semicolon any name using in this program are from the standard name space the next step is main function what is a function a function is a group of statements that are designed to perform a specific task every c program must be written in a function and the name for that function is main the execution of a c plus program starts with the main function the operation that we are to perform are written here in an opening and closing curly bracket the execution of a c plus plus program starts with the main function we will use int main in refers to the data type which is returned by the compiler we will discuss this later on the operations that we want to perform are written here in our opening and closing curly brackets the opening brackets indicates the beginning of the main program and the ending bracket or braces indicates the ending of the main function everything between these two brackets is called the body of the main function now coming to the cout is our instruction the c refers to the character and out means output it means we are going to display a character after that we use version operator in order to display any character we will use single quotes to display a string we will use double quotes it tells the compiler to display the message as shown here in double quotes
we are going to display hello on the screen the c outline which you can see is called a statement in c++ every statement is meant to perform certain operation a semicolon is used to end a statement it indicates that the statement ends here at last we use return 0.
the statement is used to return a value from a function and indicates finishing of a function coming video we are going to execute this code on dev c++ hope this is informative for you thanks for watching