#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();
}
#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();
}
If you have any doubt, let me know...