Program to calculate Simple interest using scanf() function.

 /*calculation of simple interest, taking values from user*/



#include<stdio.h>  

/*#include is a preprocessor directive and #include<stdio.h> is a declaration for printf() function*/


int main()        

 /*main() is a function or a cointainer for a set of statements*/

{

int p,n;       /*declaration*/

float r,si;    /*declaration*/

printf("input values of p,n,r"); 

scanf("%d%d%f",&p,&n,&r); 

 

//&(ampersand) is an address of operator, when we use &p we are telling scanf()at which memory location should it store the value.


   si=p*n*r/100;  //using formula for simple interest

   

   printf("%f\n",si); 

//printf() displays output on the screen, %f is used to print real value, and \n takes cursor to next line.

   return 0;       

//as we are using int before main(), it return a value 0  

}

Comments

Popular posts from this blog

Write a program to check if a number is prime or not.

Write a program to print the grades to a student.

write a program (keep taking numbers as input from user until user enters an Odd number)