Translate

Friday, April 17, 2020

Calculation of simple interest

/* Calculation of simple interest*/

#include<stdio.h>
#include<conio.h>
 void main()
{
int p, t;
float r, si;
clrscr();
printf("enter principle amount");
scanf("%d,& p);
printf(enter the value of rate");
scanf("%f,& r); 
printf(enter time");
scanf("%d,& r); 
/*formula for simple interest*/
si= p*t*r /100;
printf("\n simple interest = Rs. %f", si);
getch();
}

Useful  Notes & Tips

1.)  The scanf() function can be written as-
Scanf("control string" , address1, address2,.....);
 here you can see we are  using int and float type of variable to store the value. 
In this program
  
printf("enter principle amount");
scanf("%d,& p);

here, %d is used, which implies that one integer value should be entered as input. 
the next one is

 printf(enter the value of rate");

 scanf("%f,& r); 

in this statement %f is used, which means that a floating point number should be entered as input.

2.) \n is an escape sequence provide special formatting control. and here, \n represents new line.

3.) Simple interest is calculated by, 
simple interest = Principle*Time*Rate/100;

4.) getch() function is used to hold the screen until user gives any input or press any key.

5.) clrscr() function is a predefined function in conio.h header file. it's used to clear the screen or you can say clear the previous data of previous running program.








No comments:

Post a Comment

C program to make a calculator using the switch statement.

/*perform arithmetic calculation on integers in C language*/ #include<stdio.h> #include<conio.h> void main() {     char op;     ...