Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing
I'm such a newbie to c++ programming, and I really would appreciate the help!!
Where did I go wrong with this program ?
#include<iostream.h>
void main()
{float p,r,t,i;
cout<<"Enter the principal amount: ";
cin>>p;
cout<<"Enter the time period: ";
cin>>t;
if(t>10)
r=8;
i=p*r*t/100;
{cout<<"the interest is : "<<i;}
else
{r=12;
i=p*r*t/100;
cout<<"the interst is : "<<i;}
}
 one year ago
 one year ago
I'm such a newbie to c++ programming, and I really would appreciate the help!! Where did I go wrong with this program ? #include<iostream.h> void main() {float p,r,t,i; cout<<"Enter the principal amount: "; cin>>p; cout<<"Enter the time period: "; cin>>t; if(t>10) r=8; i=p*r*t/100; {cout<<"the interest is : "<<i;} else {r=12; i=p*r*t/100; cout<<"the interst is : "<<i;} }
 one year ago
 one year ago

This Question is Closed

Aditi_SinghBest ResponseYou've already chosen the best response.0
p.s : It says : misplaced else in function main() And, Yeah, The question was : WAP to input principal amount and time. If time is more than 10 years, calculate the simple interest at the rate of 8%, otherwise calculate is at the rate of 12% per annum
 one year ago

ShadowysBest ResponseYou've already chosen the best response.1
if(t>10) r=8; i=p*r*t/100; {cout<<"the interest is : "<<i;} else {r=12; i=p*r*t/100; cout<<"the interst is : "<<i;} notice the brackets.
 one year ago

ShadowysBest ResponseYou've already chosen the best response.1
here's the code after some debugging. #include<iostream> using namespace std; int main() {float p,r,t,i; cout<<"Enter the principal amount: "; cin>>p; cout<<"Enter the time period: "; cin>>t; if(t>10) {r=8; i=p*r*t/100; cout<<"the interest is : "<<i;} else {r=12; i=p*r*t/100; cout<<"the interst is : "<<i;} return 0; }
 one year ago

ShadowysBest ResponseYou've already chosen the best response.1
the main function must return an integer. void is for functions inside it.
 one year ago

ShadowysBest ResponseYou've already chosen the best response.1
the brackets are outside your declaration in the if statement
 one year ago
See more questions >>>
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.