Question:
Simple C++ Program to calculate simple interest?
anonymous
2012-02-06 17:11:05 UTC
I've been trying to write a program to calculate simple interest. I have coded this much but my program will not compile after several attempts! Please help! I will post my code here.

#include
#include
#include
#include
#include

void main()


using namespace std;

int main(int argc, char *argv[])

{
int p, r, t, si;
clrscr();

printf("Enter principle, rate of interest & period of time: ");
scanf("%d%d%d",&p,&r,&t);

si = (p*r*t)/100;
printf("imple interest = %d",si);


system("PAUSE");
return EXIT_SUCCESS;
}
Three answers:
anonymous
2012-02-06 20:58:59 UTC
Your correct source code in C language:

http://AlgoritmosUrgentes.com/en/c.php?f=simple_interest%3Dprinciple*interest_rate*period_of_time%2F100



Your correct source code in C++ language:

http://AlgoritmosUrgentes.com/en/cpp.php?f=simple_interest%3Dprinciple*interest_rate*period_of_time%2F100
anonymous
2016-12-13 09:17:27 UTC
Program To Calculate Simple Interest
?
2012-02-06 19:39:06 UTC
you don't need the void main(). that's probably what's causing the compiler error.



here's a fixed code:



#include

#include

#include



using namespace std;



int main(int argc, char *argv[])

{

float p, r, t, si;



printf("Enter principle, rate of interest & period of time: ");

scanf("%f%f%f",&p,&r,&t);

si = ((p * r * t)/100.0);

printf("imple interest = %.2f\n", si);



//Changed the system("pause"), as it is not safe.

printf("Press any key to continue...");

getch();



return 0;

}


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...