c++ programs error

dhruv227

New Member
Messages
390
Reaction score
1
Points
0
i made a program in c++ and getting around 4 errors, can someone find out the problem and help me rectify it, thanks

≡ File Edit Search Run Compile Debug Project Options Window Help
╔═[■]════════════════════════════ CALCULAT.CPP ══════════════════════════2═[↕]═╗
║{ ▲
║clrscr() ▒
║float d,t,interest; ▒
║cout<<"Enter the deposit"; ■
║cin>>d; ▒
║cout<<"Enter the Time Period in months"; ▒
║cin>>t; ▒
║if ((d<2000)&&(t>=24) ▒
║ { interest=5; } ▒
║ else if ((d=>2000)&&(d<=6000)&&(t=>24)) ▒
║ { interest=7; } ▒
║ else if ((d>=6000)&&(t>=12)) ▒
║ { interest=12; } ▒
║ else if (t=>60) ▒
║ { interest=10; } ▒
║ else ▒
║ {interest=3; } ▒
║cout<<"The interest on "<<deposit<<" and time period of "<<time<<" months is "▒
║getch(); ▒
║} ▒
║ ▼
╚══════ 11:15 ════◄■▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒►─┘
F1 Help Alt-F8 Next Msg Alt-F7 Prev Msg Alt-F9 Compile F9 Make F10 Menu
 

ah-blabla

New Member
Messages
375
Reaction score
7
Points
0
You're using the less/greater than or equal to signs incorrectly, you have two forms:
t=>24 and t>=24
the correct way is to have the greater/ less than sign first, so the second form is correct:
t>=24.
(There's a few of these throughout, so go through the whole program and correct them.)

The other problem I see is in the line:
Code:
cout<<"The interest on "<<deposit<<" and time period of "<<time<<" months is "▒
You haven't defined a variable deposit, you have actually stored the user's input for deposit as the variable d, and similarly for time, under t.
Code:
cout<<"The interest on "<<d<<" and time period of "<<t<<" months is "▒
There might also be other errors, I'm no c++ expert, so I wouldn't be able to tell. However it would be useful to paste the compiler errors you get here.

Oh, BTW, I think you posted this in the wrong forum. This forum is for Programming help with websites.
 
Last edited:

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
Oh, BTW, I think you posted this in the wrong forum. This forum is for Programming help with websites.

This forum is in fact for help with any type of languages
Anything about coding stuff (HTML/AJAX/PHP/CSS/Perl/Ruby/Python/etc.,)

This place is for getting help on your coding languages and scripting stuff (The Scripts & 3rd Party Apps is for programs such as Joomla and drupal like CMS scripts, not php scripts) and just to ask other people "How do you do this in php" or things like that.
http://forums.x10hosting.com/programming-help/61745-please-read.html#post354548
 

ah-blabla

New Member
Messages
375
Reaction score
7
Points
0
This forum is in fact for help with any type of languages
Well yes, but it is part of the category "Site Design & Development", which is why I wasn't sure, since this is standard coding. Then again, no one seems to be taking that rule too seriously, seeing as there is another (even a few) about website unrelated programming. (Making a separate normal programming forum would be a good idea.)
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
Well I think that it was put in the Site Design & Development category as most of the threads would be website related. However, if there was a separate generic programming category, it would only mean more work for the moderators (make sure that the help question is in the good programming forum). One generic programming help category is far more efficient.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
══════════════════════════2═[↕]═╗
║{ ▲
║clrscr() ▒

When posting code, please post just the code, which means leave out the character graphics. Are you using the old Borland C++ IDE? Also, use
Code:
 tags rather than [quote] tags. 

[quote="dhruv227, post: 585136"]i made a program in c++ and getting around 4 errors, can someone find out the problem and help me rectify it, thanks[/QUOTE]
It's rather hard to address an error when you don't [URL="http://catb.org/~esr/faqs/smart-questions.html#beprecise"]state what it is[/URL].

In addition to what ah-blabla mentions, you forgot to terminate two statements with a semicolon (the [FONT="Courier New"]clrscr()[/FONT] and final output statement) and you're missing a closing parentheses in the first [FONT="Courier New"]if[/FONT]'s test.
[code]{
    clrscr()[COLOR="Red"];[/COLOR]
    float d,t,interest; 
    cout<<"Enter the deposit";
    cin>>d; 
    cout<<"Enter the Time Period in months"; 
    cin>>t; 
    if ((d<2000)&&(t>=24)[COLOR="Red"])[/COLOR] 
    { interest=5; } 
    else if ((d>=2000)&&(d<=6000)&&(t>=24)) 
    { interest=7; } 
    else if ((d>=6000)&&(t>=12)) 
    { interest=12; } 
    else if (t>=60) 
    { interest=10; } 
    else 
    {interest=3; } 
    cout<<"The interest on "<<deposit
        <<" and time period of "<<time
        <<" months is "[COLOR="Red"];[/COLOR]
    getch(); 
}
Speaking of what ah-blabla mentions, you're doing yourself no favors in abbreviating "deposit" and "time" as "d" and "t".
 
Top