Hello students!
In our previous video lectures we have learnt the brief introduction of high level languages.
Now in this video we will learn the practical implementation of that languages.
First of all we take an example of c language program as this language is a called origin of programming.
Just have a look upon a program to calculate simple Interest.
In our routine life if we want to calculate simple interest use this simple interest formula to find interest.
Simple Interest is equal to P x R x T divided by 100.
Where P is the principal amount of money to be invested at an Interest rate R% per period for t number of time periods.
Similarly this simple interest can be calculated in c language.
See the program include stdio.h.
It is a statement which tells the compiler to insert the contents of stdio at that particular place.
Stdio is equal to hash pre processor directive and this is a header file and include in the program.
Hence include stdio.h.
2. int main:
It means int main function returns int (integer value) value we will get integer value in the output.
3. Curly braces to start the program.
They are mandatory.
4. Int amount, rate, time, si.
Here amount, rate, time and si are 4 variables taken by the user to store the data into the memory and their data type is integer.
It means these variables will store only integer type value.
5. Printf enter principal amount:
Printf is a predefined function in stdio.h header file.
By using this function user can print the data or user defined message given by user on console or monitor screen.
Here by typing above line that is printf slash n enter principal amount colon semicolon user can print the principal amount on the screen.
Next scanf bracket open inverted commas begin percentage d inverted commas closed comma & amount bracket close semicolon.
Scanf is a predefined function in stdio.h header file.
It can be used to read the input value from the keyword suppose amount entered by user is 500.
This function will take this value printf bracket open inverted commas begin slash n enter rate of interest colon inverted commas closed bracket closed semicolon.
Scanf bracket open inverted commas begin percentage d inverted commas closed comma & rate bracket closed semicolon.
Printf bracket open inverted commas open slash n enter period of time colon inverted commas closed bracket closed semicolon.
Scanf percentage d comma & time semicolon.
Similarly user can enter the rate of interest and period of time by using scanf and print that value on screen by using printf.
Si is equal to brackets open amount asterisks rate asterisks time bracket closed divided by 100 semicolon.
Here, Si is a integer type variable.
It was declared in the starting of program.
Here, formula to calculate simple interest is used.
All the values of amount rate and time will be entered by user previously and get multiplied then divided by 100 according to the formula.
Finally Si will get the amount after calculation.
Printf bracket open inverted commas begin slash n simple interest colon percentage d inverted commas closed comma si bracket closed semicolon.
Printf will print the value of si variable on the screen.
Return 0 the return value of the main function is considered the exit status of the application.
Returning 0 is a success.
Status like saying the program worked fine.
Close the program its mandatory.
Output:
Enter Principal Amount : 500, Enter Rate of interest : 5, Enter Period of Time : 2, Simple Interest : 50.
Thank you.