At line '25', I have the following error which I'm not sure how to resolve. The error is commented. I would appreciate it if someone could offer some guidance as to what I'm doing wrong. "cout<<"Balance after year "<<i+1<":\t"<<A[i]; /*error invalid operands of types 'const char [3]' and 'double' to binary 'operator<<'*/"
#include<iostream>
#include<iomanip>
#include<cmath>
usingnamespace std;
int main()
{
/* Design a program to calculate the balance in a savings account at the Cache National Bank.
The program should accept a deposit and interest rate,
then calculate and print for each of the next 10 years the interest earned
and the balance at the end of the year.
Compound Interest: A = P (1 + r/n)^(nt)*/
double A[10], P[10], r, n=1, t=10;
int i;
cout<<"\nEnter the Principal amount you wish to deposit into Savings: ";
cin>>P[0];
cout<<"\nEnter the interest rate of the savings account: ";
cin>>r;
for(i=0;i<10;i++)
{
A[i]=pow((P[i]*(1+r/n)) (n*t));
cout<<"Balance after year "<<i+1<":\t"<<A[i]; /*error invalid operands of types 'const char [3]' and 'double' to binary 'operator<<'*/
P[i+1]=A[i];
}
return 0;
}
Adding whitespace to line 25 makes the reason for the error easier to spot: cout << "Balance after year " << i + 1 < ":\t" << A[i];
As dutch points out one of the insertion operators (<<) is a single <.
Your compiler doesn't care about whitespace, it is useful when humans read the code.