• 3 months ago
Transcript
00:00Hello everyone, today I'm going to explain the syntaxes of the program. I'm going to
00:09cover those syntaxes which I haven't covered in my previous videos. I will start with main
00:19and main is a function. Now why we write the codes, why we write the steps of the program
00:28inside this main function. Why don't we start writing this code, the declaration part and
00:38then initialization part of the variable and other things directly after the header file.
00:49Why first of all we use the main function and inside the main function why we write
00:54down the things. To understand this we have to understand what is function. The meaning
01:03of function is to execute block of statement or you can say block of statements which perform
01:15any task and provide result that is known as what function. To better understand I give
01:24a realistic approach example. Any task which is to be performed that has to be gone through
01:32steps and when it's gone through steps then that task is performed that function completes
01:43and in a real life we need an entity to perform that steps. For example suppose one of the
01:54teacher has to teach any one of the topic of any subject and in the class students are
02:09there but the teacher is not present. So will the task will perform, will the function operate. No
02:22you need that entity, the teacher should be there. When the teacher goes through the steps
02:30to explain about that topic then only the students will be able to understand and if the
02:41teacher that entity is not there the task is not going to perform because the teacher is going to
02:49explain the step by step about the subject and then only the task will be performed or you can
03:01say the function is going to operate and the students are going to understand about the
03:05topic and if the teacher is absent it's not going to work. So any work which is going to perform,
03:13any work which is having the steps that is to be execute in a real world for that an
03:21entity is required. So the same architecture is here also. If these steps are to execute
03:32for that you need a function and that function is what main. So as in a real life an entity is
03:43required to go through the steps here the main function is required to go through these steps
03:50and within this main function these steps are encapsulated which is given to the processor
04:00to process step by step and the results are obtained. That's why whatever we write, we write
04:09down inside this main function. Now let us understand about the semicolon which we use
04:20at the end of the statement. I don't know that have you observe or not. If you see at the end
04:34of the main function I haven't used semicolon but at the end of the declaration of the variables I
04:43have used the semicolon and if you see at the end of this for loop statement I haven't used what
04:52semicolon. So some at the end of some of the statement I have used semicolon but at the end
05:01of some of the statements I haven't used semicolon. So what the meaning of it? When the explanation
05:12of any one of this syntax completes within a single line then you have to terminate it and
05:21you have to tell the compiler that to compile it from the next line. So we have to use what
05:28semicolon that is the end of the statement or end of the syntax. So here the declaration of
05:36the variable so meaning of it is completes within a single line that is you have to end this
05:43statement to add it to acknowledge to the compiler we have to use what semicolon. But main is not a
05:53single line statement it has to go through steps as we have just discussed that it is a function
06:00and a function that having the block of statements to perform a task so it has to go through what
06:08steps and those steps are not in a single line. For that we use what open braces that is start
06:15of the program. Start of the main function and then close braces that is here at the end that
06:24is end of the program. So we use what when a statement not ends in a single line we use what
06:42open braces for the start of the statement and the close braces for the end of the statement.
06:51So main function is not a single line statement the meaning of it only completes when you go
06:59through these steps that is of the program. In the same way if you see the for loop so the
07:06for loop is not going to complete within a single line that's why we haven't used what's
07:11semicolon at the end of it. So for that is the start of the loop if you see which is
07:20indicating that loop has started there's some work is performed and when it
07:28gone through some steps is the end of the loop okay and the same for the if statement you must
07:36have seen that at the end of this if statement we not use semicolon because it is also not a
07:43single line statement it's not going to cover in a single line. We need what open braces the true
07:50part and with the else what the false part or you can say the no part this is the yes part and is
07:56the no part. So for that when the task is performed through steps more than one steps then we use
08:11what braces the open braces for the start and close braces for the close. So I explained both
08:19the things why we use the semicolon and why we use open braces and the close braces. When the
08:28explanation is in more than one lines in more than one steps for that we use open braces and
08:38close braces that's why for the start of the function we use open braces for the start of
08:45the loop we use open braces for the start of the if statement we use open braces and for the end
08:53of the function we use close braces for the end of the loop use close braces and for the end of
09:00the if statement also we use what close braces. For the indication of the start and the close of
09:08function loop and if statement.
09:16So I hope I have explained all the syntaxes which is used inside the program. I have explained about
09:24the header files why we use hash include. I have explained in my previous video about the
09:30header files and the hash include. I have explained about what happens when we declare the
09:37variables okay and why we use the ampersand sign why the specifiers are used okay and here I have
09:50used what data type int with the main function it means it should return so it is returning the
10:00return zero value which indicates the exit status that everything is fine we got the result it is
10:09indicated by written zero. In the next video I'm going to explain something else. Thanks for today.

Recommended