C/C++ program to calculate simple interest, Program to find Simple interest by entering rate, principle amount & number of year
Program#include<stdio.h>
#include<conio.h>
main( )
{
int p, n ;
float r, si ;
Printf("Enter the principle amount");
scanf("%d", &p)
Printf("Enter the number of years");
scanf("%d", &n)
printf("Enter the rate of interest");
scanf("%f", &r)
si = p * n * r / 100 ;/* formula for simple interest */
printf ( "%f" , si ) ;
Changes for C++
If you want to write the same program in c++ apply the following changes to the program.
1.) change the header file from "#include<stdio.h>" to "#include<iostream>.h"
2.) for input & output use "cout<<" & "cin>>" instead of "printf" & "scanf".
3.) don't use "% "symbol and "&" sign in "cin>>" statement.
Click here to check Output
No comments:
Post a Comment