Learn Programming Technique C to Master Skills - Explanation of First Program of C Language in Code - Blocks

  • last week
Transcript
00:00Hello everyone, this is Sandeep.
00:06In my last video, I have explained the flowchart of SimpleIntest.
00:11And in that flowchart, I have explained how to take variables and then to initialize it.
00:22So this is the flowchart and here I have initialized the values of variables, the four variables
00:31I have declared as p, r and t and I have initialized the value of principal, time and rate of interest.
00:38Then I have applied the formula okay and after that resulted values stored inside at s and
00:46then it is displayed.
00:48So this is the program and today I'm going to implement this program in C and I'm going
00:57to make the program in code blocks.
01:00So let me open the code blocks to make the program.
01:07When we take the variables, when we declare the variables, the memory locations will allocate
01:18inside the random access memory as we have taken four variables.
01:23So four memory locations are going to allocate inside random access memory, one for p, another
01:29for t and for r and then for s.
01:33So inside this bigger location, RAM is a bigger location, the four small location or you can
01:38say the sub locations are going to create that is p, t, r and s.
01:44Then I have initialized the value, I have given the fixed value, I have given the fixed
01:48value of principal, I have given the fixed value of time and rate of interest.
01:53Calculation will take place, I have written the formula, the calculation will take place,
01:57the resulted value is going to store inside s and then by print s, the resulted value
02:04is going to display on the screen.
02:06So whenever I will run this program, I am going to get the same result as the values
02:14of principal, rate of interest and time are same.
02:18I have initialized it, that's why whenever I will run this program, I am going to get
02:25the same result which is stored inside s.
02:29Now I am going to implement the same program inside the code blocks, this is the code blocks
02:36and how to make the program, let us see.
02:39For it, I will go to file, then I will click on new, here I am having what empty file,
02:45I will click on it and again I will go to file, then I will come to what save file,
02:51I give a name to it, prgnew1 something like this and then what save, then I will use the
03:04header file and that header file is what stdio.h, inside it I will use what int main and then
03:15I will declare the variables that is int s for simple interest, p for principal, r for
03:21rate of interest, t for time.
03:25Here what I will do, I will give the fixed values as there in the program, in the flow
03:34chart, so the principal is 1000, time is 2 and r is rate of interest is 3, so same values
03:44I am going to give, r is 2, r is 3 and t is what 2, so rate of interest 3 and time
03:56is what 2.
03:58So I have initialized the value of principal, rate of interest and time.
04:02Now what I have to do, I have to apply the formula s equals to p into r into t upon 100.
04:11So I have started with very simple program, so everyone can understand it, then slash
04:17n int type slash n simple enter interest is type a specifier percent d, where is the value
04:28inside s, semicolon and that at the end what return 0 as it will indicate that there is
04:39no error in the program, everything is fine, let's give the indication to the operating
04:43system that after run the programs will terminate without error.
04:51So this is the program friends and I am going to explain each and everything, what is the
04:57meaning of hash include, why to use hash include in our program, what is the meaning of stdio.h,
05:05why to include the standard input output header file in the program, why always we
05:09start the program with the main, what happens when we declare the variables, why to use
05:14semicolons at the end of the statements, why to use return 0, as I have just told you that
05:25it shows that there is no error in the program and it's going to terminate successfully,
05:34that's why we use what return 0.
05:37So I am going to click now on the build button, here you will see what build button, when
05:44I click on this, it's going to compile and it shows that there is no, there is zero and
05:50the zero warning.
05:51Now intentionally what I will do, I will remove the semicolon from one of the statement and
05:59again save it by using ctrl s and go to build okay, when I click on it, now it's showing
06:06me the error, see what the error it's now showing that expected semicolon before printf,
06:15it's showing me, it's showing the red box and showing me that above printf you haven't
06:20used the semicolon at the end of the statement.
06:24So I will go here with the semicolon, again save the program by use of ctrl s and again
06:30I will, I'm going to click on what build button, this is the build button okay, now it's showing
06:36what zero error and zero warning, so now the program is error free, I'm going to run it,
06:42so when I click on the run button, it's showing with a simple inter 60.
06:46So whenever I'm going to run this program, it's going to give me the same result as the
06:52values are what fix 60 okay, so I hope you understand how the program run and we get
06:59the result.
07:00In the next video, I'm going to input the values of principal rate of interest and time
07:06okay and then I'm going to calculate the simple interest, so I'm going to input the values
07:11of principal rate of interest in time and then I'm going to calculate the simple interest
07:16and then it's going to display, thanks for today.

Recommended