+ Reply to Thread
Results 1 to 7 of 7

Thread: c++ programs error

  1. #1
    dhruv227 is offline x10 Lieutenant dhruv227 is an unknown quantity at this point
    Join Date
    Dec 2008
    Location
    da capital
    Posts
    390

    c++ programs error

    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

  2. #2
    ah-blabla's Avatar
    ah-blabla is offline x10 Lieutenant ah-blabla is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    375

    Re: c++ programs error

    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 by ah-blabla; 10-10-2009 at 05:27 AM.

  3. #3
    dhruv227 is offline x10 Lieutenant dhruv227 is an unknown quantity at this point
    Join Date
    Dec 2008
    Location
    da capital
    Posts
    390

    Re: c++ programs error

    thanks for the help

  4. #4
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: c++ programs error

    Quote Originally Posted by ah-blabla View Post
    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
    Quote Originally Posted by kkenny View Post
    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.
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  5. #5
    ah-blabla's Avatar
    ah-blabla is offline x10 Lieutenant ah-blabla is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    375

    Re: c++ programs error

    Quote Originally Posted by xav0989 View Post
    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.)

  6. #6
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: c++ programs error

    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.
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  7. #7
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: c++ programs error

    Quote Originally Posted by dhruv227 View Post
    ══════════════════════════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 Originally Posted by dhruv227 View Post
    i made a program in c++ and getting around 4 errors, can someone find out the problem and help me rectify it, thanks
    It's rather hard to address an error when you don't state what it is.

    In addition to what ah-blabla mentions, you forgot to terminate two statements with a semicolon (the clrscr() and final output statement) and you're missing a closing parentheses in the first if's test.
    Code:
    {
        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(); 
    }
    Speaking of what ah-blabla mentions, you're doing yourself no favors in abbreviating "deposit" and "time" as "d" and "t".
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Replies: 2
    Last Post: 03-18-2009, 03:19 PM
  2. 500 Internal Server Error on cossacks
    By tletter in forum Free Hosting
    Replies: 1
    Last Post: 12-03-2008, 07:27 PM
  3. Error en mi host
    By roonline in forum Soporte
    Replies: 17
    Last Post: 11-14-2007, 03:28 PM
  4. 500 Internal Server Error (PHP Error?)
    By aniklaus in forum Free Hosting
    Replies: 3
    Last Post: 11-12-2007, 11:47 AM
  5. {req} Banners
    By SEŅOR in forum The Marketplace
    Replies: 23
    Last Post: 01-05-2006, 03:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers