I want to write a program to input principle amount and time . if time is >10 yrs.Calculate the simple interest with rate 8%.otherwise calculate it with 12% per annum and here's my incorrect code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int p,t,r,si,si1;
cout<<"enter the time";
cin>>t;
cout<<"enter the principle";
cin>>p;
{if(t>10)
si=((p*8*t)/100);
cout<<"the simple interest is "<<si<<endl;}
else
{si1=((p*12*t)/100);
cout<<"the simple interest is"<<si1}
getch();}
add std:: before each call of cin and cout or add usingnamespace std; at the beginning of your program (aftrer including headers)
correct line 10 like this: if(t>10){
add the missing ';' in line 15 cout<<"the simple interest is"<<si1;}
I think you are working in turbo c++.
correct line 10 like this: if(t>10){
add the missing ' ; ' in line 15 cout<<"the simple interest is"<<si1;}
rest of the code is correct.