Thread: Need a challenge

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    6

    Need a challenge

    Hey guys,

    I'm kind of new to programming, and i set my self a task to make a program that find 25% of any number, well i did it in a couple of hours using the following code

    Code:
    #include <iostream>
    
    using namespace std;
    
    float main()
    {
     float num1;
    
    
     {
     cout <<"this a simple percentage program";
     cout <<endl;
     cout <<"to find 25% of any number";
     cout <<endl;
     }
     float x = 10;
     while ( x = 10 ){
     cout <<"insert the number you want to find 25 percentage of:  ";
     cin >> num1;
     cout <<"the percentage of:  "<< num1 << endl;
     cin.get();
     cout <<"would be: "<< 25 * num1 / 100 << endl;
     cin.get();
     x++;
     }
    
     return 1;
    }
    Now i feel i need a new task but can't think of anything suitable, so I wonderd if you guys and gals had any ideas?

    Thanks
    Dave

  2. #2

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    Now i feel i need a new task but can't think of anything suitable
    How about a program that finds 26% of a number?

    Then consider this: why do you want to learn a language you have no use for?
    Last edited by 7stud; 10-25-2005 at 11:56 AM.

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Your next task should be to change your existing code to be more correct. For example, main should specify int as its return value, not float. Also, while (x = 10) is not what you want. Remember (or learn) the difference between assignment and equality. Finally, standard practice is to return 0 to signify success. Better code formatting would also be a good thing to practice with a working program.

  5. #5
    Registered User
    Join Date
    Sep 2005
    Posts
    6
    Quote Originally Posted by 7stud
    Then consider this: why do you want to learn a language you have no use for?
    I want be a games programmer when i'm older, i need somewhere to start right?, I can't jump straight in i need to work my way up. before i can start practicing that kind of stuff, i need to know basics and get used to everything.

  6. #6
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    I want be a games programmer when i'm older
    Now i feel i need a new task but can't think of anything suitable

  7. #7
    Registered User
    Join Date
    Sep 2005
    Posts
    6
    I know what your saying, but i still don't think i have enough skillz to make a basic game..

  8. #8
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Don't worry about making a game yet. Just learn good programming habits (see my previous post) and do some easy programs until you can do them well. I believe there are some problems you can work on from this site's main pages.

    One common problem that would fit as an extension to your current code is to make a calculator program. Start simply, with addition only, and expand it one step at a time.

  9. #9
    Registered User
    Join Date
    Sep 2005
    Posts
    6
    Quote Originally Posted by Daved
    D
    One common problem that would fit as an extension to your current code is to make a calculator program. Start simply, with addition only, and expand it one step at a time.
    hehe that was actually an idea i had , but wasn't sure, i'll try it, should be harder than the percentage one.

    just to add, i made it float becuase it returns results with decimal
    points.

  10. #10
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Why not make a very simple text based game? That way you can learn to use classes, which is extremely important.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  11. #11
    Registered User
    Join Date
    Oct 2005
    Posts
    23
    Quote Originally Posted by grohyt
    just to add, i made it float becuase it returns results with decimal points.
    You're actually wrong there. The function main() itself does not return results in decimal points... It returns a 1. You're perhaps thinking that what you output to the user (which might be a decimal point) is actually what main() returns, which as stated is not the case. Read a little bit about functions in C++ and you'll hopefully understand what I mean.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. AI Challenge
    By unknown_111 in forum General AI Programming
    Replies: 0
    Last Post: 10-02-2007, 12:18 AM
  2. A Challenge in C++
    By Brad0407 in forum C++ Programming
    Replies: 38
    Last Post: 07-18-2007, 12:56 PM
  3. Programming Challenge (for my school)
    By Ezerhorden in forum C++ Programming
    Replies: 2
    Last Post: 01-04-2006, 06:56 AM
  4. Challenge?
    By Mackology101 in forum C Programming
    Replies: 5
    Last Post: 11-23-2004, 02:30 PM
  5. Requesting a challenge
    By RealityFusion in forum C++ Programming
    Replies: 8
    Last Post: 08-18-2003, 08:24 PM