What kind of programs should I start writing?

This is a discussion on What kind of programs should I start writing? within the C++ Programming forums, part of the General Programming Boards category; Hi. I just started programming in C++, and, quite frankly, its hard the first time. I suppose its because its ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    4

    What kind of programs should I start writing?

    Hi.
    I just started programming in C++, and, quite frankly, its hard the first time.
    I suppose its because its because I'm only 12 and BASIC is all i used till now ( =/ ) If I could get some suggestions as to what kind of programs i Should write with my little time of C++ programming.

    thx in advance

  2. #2
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Start with hello world. I'll paste it below. Play around with it, cause errors and fix them, change the message, maybe take some form of input, and dont forget to check out our tutorials!

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
        cout << "Hello World!" << endl;
        return 0;
    }

  3. #3
    _ Munkey01's Avatar
    Join Date
    Dec 2002
    Posts
    280
    Once you do get some basics down you can create programs that just base around what you just learned so that you are practicing. These programs don't need to be of any use other than supplying a learning experience.

  4. #4
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    I must say i'm very impressed by your demeanor; being 12 and all. Most 12 year olds act like retards on the internet.

    Okay, so what have you accomplished so far? What's the "best" thing you've done in BASIC so far? What have you done in C++?

  5. #5
    Registered User SAMSAM's Avatar
    Join Date
    Nov 2001
    Posts
    218
    "because I'm only 12 and BASIC is all i used till now "

    Excellent!

    BASIC is a robust language.

    Start by some concept tutorial(OOP) .and the
    rest should come to you easily as you go further.

    have fun & good luck.

  6. #6
    Registered User
    Join Date
    Apr 2003
    Posts
    4
    Thanks for all the info!
    But i have one small qustion, or it may be a large question, depending on how you interpret it;
    How do I take input without using Cin?

    thanks

    [Edit]

    Here is some BASIC code I have writen:
    Code:
    ] spacedtokens on
    
    cls
    set console title to ""
    Print "To indicate class, type one of the following:"
    Print "Warrior (1)"
    Print "Warlock (2)"
    input class
    ' preliminary matters
    
    if class = 1 then life = 250
    if class = 1 then mana = 100
    
    if class = 2 then life = 100
    if class = 2 then mana = 310
    
    if class = 1 then classchar$ = "Warrior"
    if class = 2 then classchar$ = "Warlock"
    
    clvl = 1
    maxclvl = 99
    mlvl = 1
    maxmlvl = 97
    
    
    cls
    
    print "Life: ";
    print life
    
    print "Mana: ";
    print mana
    
    ' armor
    
    If armor = clothes then armdef = 12
    If armor = link mail then armdef = 24
    If armor = chain mail then armdef = 28
    If armor = plate mail then armdef = 36
    If armor = full plate mail then armdef = 43
    
    ' sheilds
    
    If sheild = buckler then shldef = 5
    If sheild = kite sheild then shldef = 12
    If sheild = luna then shldef = 22
    If sheild = pavis then shldef = 36
    
    ' helms
    
    If headgear = leather cap then heldef = 2
    If headgear = skull cap then heldef = 6
    If headgear = helm then heldef = 14
    If headgear = sallet then heldef = 21
    
    totaldef = armdef + shldef + heldef
    
    ' weapons
    
    If weapon = falchion then dmg = 2
    If weapon = bludgeon then dmg = 1
    If weapon = axe then dmg = 4
    If weapon = long sword then dmg = 8
    If weapon = serrated blade then dmg = 12
    If weapon = enchanted blade then dmg = 18
    
    chardmg = dmg + clvl
    
    ' Combat
    ' Sequences Operators
    
    if chardmg < monlife then
    mon = 1
    end if
    
    if chardmg > monlife then
    mon = 0
    end if
    
    
    'Level One : Escape
    
    for x = 1 to  5
    print ""
    next x
    
    print "                               Stage One : Escape"
    
    
    print "What is your name?"
    input name$
    
    cls
    
    print "Welcome, ";
    print name$;
    print ", the ";
    print classchar$;
    print ", ";
    print "to the castle of Leviathan. You must leave now. The king has gone insane and sends the hypnotiezed guards to kill you."
    
    wait 3
    
    cls
    
    print "Life: ";
    print life
    
    print "Mana: ";
    print mana
    
    print ""
    print ""
    print ""
    cls
    
    Battle:
    
    mdef = 21
    mlife = 100
    enemy$ = "crazed guard"
    
    
    print "An Enemy Approaches"
    print ""
    print "Enemy : ";
    print enemy$
    print "Life : ";
    print mlife
    print "Defense : ";
    print mdef
    
    print "You attacked the Crazed guard"
    
    weapon = falchion
    
    result = chardmg - monlife
    
    print "You attack with your weapon(falchion)"
    
    Print ""
    print ""
    print "Your opponent has ";
    print result;
    print " life left"
    
    print "Attack again?"
    input att$
    
    result2 = result - chardmg
    
    if att$ = "yes" then
       print "Your foe has ";
       print result2;
       print " ";
       print "life left"
    end if
    Last edited by Macabre; 04-12-2003 at 07:19 AM.

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    1,109
    Originally posted by Macabre

    How do I take input without using Cin?
    cin is standard io for console apps. you can use scanf or other c fxns, but if you want to keep it c++ and you're writing a console app, you shall use cin.

  8. #8
    Registered User
    Join Date
    Apr 2003
    Posts
    4
    Thanks, I'll stick with Cin

  9. #9
    _ Munkey01's Avatar
    Join Date
    Dec 2002
    Posts
    280
    Code:
    int age;
    std::cout << "What's your age?: ";
    std::cin >> age;
    std::cout << "You are " << age << " years old.";
    Note: The std:: part is not needed if you put "using namespace std;" at the top of the program. But it is good to know what namespace things are a part of.

  10. #10
    Registered User
    Join Date
    Apr 2003
    Posts
    18

    getline

    I'm rather new to c++ as well, but I think that 'cin >>' will stop once it hits it's first whitespace. So if you're going to be entering strings at some point that have spaces, you can use
    Code:
    #include <string>
    #include <iostream>
    
    int main() {
    
    string char_name;
    
    cout << "Please enter the name: "
    getline(cin, char_name);
    
    cout << "\nYour character's name is: " << char_name << endl;
    
    
    return 0;
    }

  11. #11
    The Pantless Man CheesyMoo's Avatar
    Join Date
    Jan 2003
    Posts
    262
    Don't you need to use the getline() member function?

    Code:
    char string[20];
    
    cin.getline(string,20);
    If you ever need a hug, just ask.

  12. #12
    Registered User
    Join Date
    Apr 2003
    Posts
    18
    You don't need to. With the exception of a missing ';', my code works fine. But there are many different ways of doing the same thing in c++, so I guess it's whatever suits you better.

  13. #13
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    916
    Macabre,
    I too began programming in C++ when i was.... eh... 11 going on 12, and I found that reading a mix of online tutorials and books helped me the most. I also noted that as I got a little older (not much older- I'm only 14) it was easier for me to understand the earlier Greekish writing of some tutorials. Read an algebra book; it is the sibling to programming. But above all else, don't expect anybody in the school system to teach you, because they won't because they are STUPID.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  14. #14
    _ Munkey01's Avatar
    Join Date
    Dec 2002
    Posts
    280
    CodeMonkey, I too am 14.

  15. #15
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361
    Originally posted by CodeMonkey
    But above all else, don't expect anybody in the school system to teach you, because they won't because they are STUPID.
    You're only 14, you know NOTHING. The sooner you realize this the better. You may think you know better than the teachers, but you're dead wrong.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Frequent Programs List in the Start Menu
    By patrick22 in forum Windows Programming
    Replies: 2
    Last Post: 04-21-2008, 09:04 PM
  2. Writing an article
    By jverkoey in forum Game Programming
    Replies: 24
    Last Post: 03-02-2003, 10:38 PM
  3. Who here programs for a living?
    By fastmonkey in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 12-27-2002, 04:52 PM
  4. Where to start?
    By Chizzlah in forum C++ Programming
    Replies: 4
    Last Post: 08-14-2002, 11:37 AM
  5. Where is a good place to start?!
    By bobthefish3 in forum Game Programming
    Replies: 1
    Last Post: 10-09-2001, 12:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21