0

# This code giving me error, Im suppose to calculate compound interest. Kindly help me

#include <iostream> #include <math.h> using namespace std; int main() { float principal,rate,time,compound_interest,; cout << " Enter principal Amount "; cin>>principal; cout << " Enter Rate "; cin>>rate; cout << " Enter Time period in years "; cin>>time; compound_interest=Principal*pow((1+rate/100),time)-principal; cout<< "The compound interest after compounded for the amount "<<principal<<" for "<<time<<" years at "<<rate<<" % is "<<compound_interest; return 0; }

20th Mar 2020, 11:16 AM
Bismark Abban + 3
Bismark Abban you should remove ,(comma) after compound_interest (before Cout<<"Enter principal amount ") And (below cin>>time) line change principal (capital P to small p)
20th Mar 2020, 11:27 AM
Nandan + 2
#include <iostream> #include <math.h> using namespace std; int main() { float principal,rate,time,compound_interest; cout << " Enter principal Amount "; cin>>principal; cout << " Enter Rate "; cin>>rate; cout << " Enter Time period in years "; cin>>time; compound_interest=principal*pow((1+rate/100),time)-principal; cout<< "The compound interest after compounded for the amount "<<principal<<" for "<<time<<" years at "<<rate<<" % is "<<compound_interest; return 0; }
20th Mar 2020, 11:21 AM
Nandan + 1
Bismark Abban you have used char datatype so it takes only first character from input Use string instead of char
20th Mar 2020, 12:26 PM
Nandan 0
thank you very much.. it worked
20th Mar 2020, 12:06 PM
Bismark Abban 0  