Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: BEHOLD MY GREATNESS! (first complicated c++ program)

                  
   
  1. #1
    DCEmu Legend Cap'n 1time's Avatar
    Join Date
    May 2004
    Location
    Right behind you...
    Age
    37
    Posts
    4,547
    Rep Power
    121

    Default BEHOLD MY GREATNESS! (first complicated c++ program)

    I have been taking a c++ class for about 2 weeks. Ive done some silly little things using the standard cpp libraries but nothing really complexed.

    Anyone whos taken a programming class will probably be familiar with this one. It is the Fibonacci program where you determine the nth number of the sequence. Mine has a slight twist however. The book wants me to use the sequence to determine how asexual things reproduce. In other words... basically you just multiply the initial value by the "final sum" which is actually just the place in the fibonacci sequence you determined.

    BEHOLD MY CODE!
    ---------------------------

    //Greatest program in the world.
    //By: Alan Gardner

    #include <iostream>
    using namespace std;

    int main()
    {
    int count;
    // long long is HUGE! alast and blast are initialized.
    long long alast, blast, sum, n;
    int totamnt;
    alast = 0;
    blast = 1;
    // Determines place in the sequence.
    cout << "Enter time: ";
    cin >> n;
    cout << "\n";
    // Determines inital amount (what to multiply final sum by).
    cout << "Enter total amount: ";
    cin >> totamnt;
    cout << "\n";
    switch (n)
    {
    // Catches 0 before it outputs a negative number.
    case 0: cout << "0"; break;
    // Catches 1 before it outputs 0.
    case 1: cout << 1 * totamnt; break;
    default:
    // Determines place in the sequence.
    for (count= 0; count < n-1; count++)
    {
    // "Rolls" numbers around to make the sequece work.
    sum = alast + blast;
    alast = blast;
    blast = sum;
    };
    // Outputs the place in the sequence multiplied by the initial ammount.
    cout << "\n" << sum * totamnt << " is the total amount."; break;
    }
    return 0;
    }

    -----
    Since there are no extra libraries, you should be able to just compile right away.

  2. #2
    The Gaming Wolf wolfpack's Avatar
    Join Date
    Jan 2006
    Location
    at my house?
    Age
    35
    Posts
    1,155
    Rep Power
    0

    Default

    i tried running this on DarkBasic... didnt work... oh well, sorry i cant see your greatness banhammer!

  3. #3
    DCEmu Coder splodger15's Avatar
    Join Date
    Jun 2006
    Location
    London
    Age
    34
    Posts
    4,123
    Rep Power
    95

    Default

    Nice work Capn 1 Time

    PSN ID: splodger15

  4. #4
    DCEmu Coder Safari Al's Avatar
    Join Date
    Mar 2007
    Location
    http://homebrewheaven.net
    Posts
    863
    Rep Power
    0

    Default

    wow i need to take a course to help me learn c. (Even though i know nothing about it lol)

    Congrats Cap'n 1 time
    Come Visit Homebrew Heaven, Where you'll find the latest gaming news and downloads!

    View My Coding Blog


    The Return of The Lounge!
    Mario Gold Rush
    Current C++ Project: To be Announced soon on Homebrew Heaven

    Currently Coding in: C++ for the PSP

  5. #5
    DCEmu Old Pro SnesR0X's Avatar
    Join Date
    Sep 2006
    Location
    Canada, Ruler of Patriarch of Constantinople and Vicar of the Hagia Sofia
    Age
    34
    Posts
    1,609
    Rep Power
    108

    Default

    lol, I only know html

  6. #6
    DCEmu Legend Cap'n 1time's Avatar
    Join Date
    May 2004
    Location
    Right behind you...
    Age
    37
    Posts
    4,547
    Rep Power
    121

    Default

    Quote Originally Posted by wolfpack99997 View Post
    i tried running this on DarkBasic... didnt work... oh well, sorry i cant see your greatness banhammer!
    I dont know about darkbasic, but im pretty sure it wont compile c++. I've never used it, but Dev c++ is supposed to make the compilation process easy for windows.

    try this.

    Quote Originally Posted by Safari Al
    wow i need to take a course to help me learn c. (Even though i know nothing about it lol)
    I highly recommend you take a beginners programming logic class before you take any computer languages. Without that class last semester I would be lost. Some people are able to pick the logic up right away... but I was not one of them.

    the cplusplus.com website offers some good tutorials. Also keep in mind that C and C++ are similar, but are not the same.

  7. #7
    DCEmu Old Pro mcdougall57's Avatar
    Join Date
    Jul 2006
    Posts
    1,324
    Rep Power
    74

    Default

    if you really wanna be up to date id recommend you take c#

  8. #8
    DCEmu Legend Cap'n 1time's Avatar
    Join Date
    May 2004
    Location
    Right behind you...
    Age
    37
    Posts
    4,547
    Rep Power
    121

    Default

    Quote Originally Posted by mcdougall57 View Post
    if you really wanna be up to date id recommend you take c#
    Thats silly. everything that I want and need to do can be done in C++ or C. The work place (generally) does not give a rats ass what language I use so long as I get the work done (though they usually demand a C derivative it seems). I know a few coders in these forums who would gladly burn you at the stake for saying such things.

    Some people would actually argue that I'd be better off primarily using C rather than C++ while others would just say to code in whatever I am most comfortable in. New is not always better.

  9. #9
    DCEmu Legend DarthPaul's Avatar
    Join Date
    Apr 2006
    Location
    Puerto Rico
    Age
    35
    Posts
    2,734
    Rep Power
    90

    Default

    Wow! You actually coded something in C++ !!
    Impossible! That's something out of this world ! You deserve a trophy!

  10. #10
    DCEmu Old Pro
    Join Date
    May 2006
    Posts
    1,386
    Rep Power
    105

    Default

    im taking ms dos then moving on to visual basic c++, who knows? i might make an app for the psp that uses the computer someday

    BTW i only got as far as inputing co ordinates and making lines and playing music in MS DOS and also using the loop command lots

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •