Technology has advanced to the point where programming has become an essential part of our lives. We use software and applications for communication, entertainment, education, and work, and these are all built on programming languages.

Program 5: Find Simple Interest from given principal,time and rate.

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int p=1000;
int t=2;
int r=3;
float si;
si=p*t*r/100;
printf("Simple Interest=%.2f",si);
getch();
}




Output
Simple Interest=60.00




Explanation
Here, p is a principal, t is time and r is a rate variable and the value is already assigned on them and are declared as integer. si denotes to simple interest that stores floating value. After applying formula in the process section, the output is printed. To bring the result in two decimal value we kept .2f specifier.


Exercise
Find the errors in the following program
#include<studio.h>
#include<conio.h>
void main()
{
integer a=30;
integer b=40;
integer c=60;
float d;
d=aXbXc/3
print("The average marks is=%d",d);
getch();
}
Share:

No comments:

Post a Comment

If you have any doubt, let me know...

Translate

Wikipedia

Search results