My Journy Into Programming

Go down

My Journy Into Programming Empty My Journy Into Programming

Post by CivBase on Fri Feb 13, 2009 10:14 pm

So, after wanting to learn C++ for about a year, I finally bought a C++ For Dummies book about a month ago. Since then, I have been reading it... and rereading it. Hey, it's hard to learn a programming language when you haven't even bothered to install the compiler yet Very Happy. So, I installed the compiler yesterday and backed it up on my jump drive and today at school I made my first program!

It's brain-dead-simple and isn't exactly a Photo Shop or a revolutionary new software... but it's a start. You can download it here. Basically, it just averages the numbers you punch in. If you've got any simple improvements for the program, it'd be appreciated. Otherwise, I'm going to continue my reading and hopefully be able to do more than this by the end of the next few weeks.

_________________
My Journy Into Programming Bzsigy2
CivBase
CivBase
Adbot

Male Number of posts : 7336
Location : Etchisketchistan
Registration date : 2008-04-27

http://pathwaygames.forumotion.net/

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by Dud Doodoo on Fri Feb 13, 2009 10:18 pm

You're really behind, I was creating dynamic runescape macros when I was 11.

Dud Doodoo
Minion

Male Number of posts : 1528
Age : 25
Location : Okinawa, Japan
Registration date : 2008-06-29

http://www.moddb.com/mods/broken-arrow-the-world-in-conflict-vie

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by CivBase on Fri Feb 13, 2009 10:21 pm

lol, sry if my simpleness does not please you. I didn't even have high-speed internet at 11.

_________________
My Journy Into Programming Bzsigy2
CivBase
CivBase
Adbot

Male Number of posts : 7336
Location : Etchisketchistan
Registration date : 2008-04-27

http://pathwaygames.forumotion.net/

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by Toaster on Fri Feb 13, 2009 11:08 pm

dud wrote:You're really behind, I was creating dynamic runescape macros when I was 11.

Get over yourself
Toaster
Toaster
Lord's Personal Minion

Male Number of posts : 2715
Age : 26
Location : Ohio
Registration date : 2008-06-19

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by Dud Doodoo on Fri Feb 13, 2009 11:47 pm

Well it's true...

Dud Doodoo
Minion

Male Number of posts : 1528
Age : 25
Location : Okinawa, Japan
Registration date : 2008-06-29

http://www.moddb.com/mods/broken-arrow-the-world-in-conflict-vie

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by L0d3x on Sat Feb 14, 2009 5:08 am

When I was 11 I was actually playing outside with other kids.
Civ: here's a great tutorial site for C++ that I used a while ago when learning it myself
http://www.cplusplus.com/doc/tutorial/

And yea, it's the first one that pops up on google, but it's there for a reason.
If you ever get far enough that you wanna mess around with Direct3D, I can give you great links to that stuff too. Same goes for game physics.

L0d3x
Minion

Male Number of posts : 162
Registration date : 2009-01-10

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by CivBase on Sat Feb 14, 2009 8:18 am

Thx

_________________
My Journy Into Programming Bzsigy2
CivBase
CivBase
Adbot

Male Number of posts : 7336
Location : Etchisketchistan
Registration date : 2008-04-27

http://pathwaygames.forumotion.net/

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by BBJynne on Sat Feb 14, 2009 1:31 pm

Dud Doodoo wrote:You're really behind, I was creating dynamic runescape macros when I was 11.
you were playing runescape
your point is invalid

BBJynne
The Lord's Blood Knight

Male Number of posts : 5059
Age : 27
Registration date : 2008-03-24

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by Lord Pheonix on Sat Feb 14, 2009 8:15 pm

He was playing runescape SO much that he created a VERY dynamic macro for it lol

_________________
My Journy Into Programming Pheonix92
Lord Pheonix
Lord Pheonix
Lord Of The Flames

Male Number of posts : 7572
Registration date : 2008-03-23

https://crimsonflame.forumotion.com

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by KristallNacht on Sat Feb 14, 2009 8:22 pm

so that he could play while he played
KristallNacht
KristallNacht
Unholy Demon Of The Flame

Male Number of posts : 5087
Location : San Diego, California
Registration date : 2008-06-24

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by Lord Pheonix on Sat Feb 14, 2009 8:25 pm

and game while he games


Last edited by Lord Pheonix on Sat Feb 14, 2009 9:05 pm; edited 1 time in total
Lord Pheonix
Lord Pheonix
Lord Of The Flames

Male Number of posts : 7572
Registration date : 2008-03-23

https://crimsonflame.forumotion.com

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by PiEdude on Sat Feb 14, 2009 8:48 pm

Dud Doodoo wrote:You're really behind, I was creating dynamic runescape macros when I was 11.
At least he doesn't have malaria...

Anyway, does anyone know where I can get a free(and preferably legal) graphic design/programming software?
PiEdude
PiEdude
Crimson Jester

Male Number of posts : 4573
Age : 26
Location : In the middle of a hollowed crust.
Registration date : 2008-03-24

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by KristallNacht on Sat Feb 14, 2009 9:42 pm

I know free. but I've never heard of any good legal free ones
KristallNacht
KristallNacht
Unholy Demon Of The Flame

Male Number of posts : 5087
Location : San Diego, California
Registration date : 2008-06-24

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by kslidz on Sat Feb 14, 2009 9:57 pm

This thread made my eyes water it was really funny
But I'll probably use it as a reference since I am trying to do this sorts stuff soon

kslidz
Minion

Male Number of posts : 753
Age : 28
Location : your pants
Registration date : 2009-02-13

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by Dud Doodoo on Sun Feb 15, 2009 9:40 pm

KristallNacht wrote:so that he could play while he played
Actually the macro was meant so I could leave it and it would play for me so I could say i was a level 126.

Those days are over, but I did do some pretty complex programs in pascal.

Dud Doodoo
Minion

Male Number of posts : 1528
Age : 25
Location : Okinawa, Japan
Registration date : 2008-06-29

http://www.moddb.com/mods/broken-arrow-the-world-in-conflict-vie

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by CivBase on Wed Feb 18, 2009 3:12 pm

*is trying to figure out a way to simplify fractions*
I think I've got it... but there's an error I can't seem to figure out. If anyone's got a simple method to simplify fractions that can be written out in math terms, that'd be helpful.

_________________
My Journy Into Programming Bzsigy2
CivBase
CivBase
Adbot

Male Number of posts : 7336
Location : Etchisketchistan
Registration date : 2008-04-27

http://pathwaygames.forumotion.net/

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by L0d3x on Wed Feb 18, 2009 3:54 pm

Just find the greatest common divisor and divide numerator and denominater by it.
(I hope I'm not mixing up my mathematical terms here, remember english != primary language)

L0d3x
Minion

Male Number of posts : 162
Registration date : 2009-01-10

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by LH Justin on Wed Feb 18, 2009 4:24 pm

So, you've invented the calculator. Congratulations. Tounge
LH Justin
LH Justin
Crimson Annoyance

Male Number of posts : 700
Age : 24
Location : United States
Registration date : 2008-07-14

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by L0d3x on Wed Feb 18, 2009 5:05 pm

Eh, its a common example to get people started.
I still remember the days that I made syntax errors :'(

L0d3x
Minion

Male Number of posts : 162
Registration date : 2009-01-10

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by CivBase on Wed Feb 18, 2009 7:54 pm

L0d3x wrote:Just find the greatest common divisor and divide numerator and denominater by it.
(I hope I'm not mixing up my mathematical terms here, remember english != primary language)
Well, I tried this. Finding the greatest common factor is the hard part though...

I'll post the test code I made for this.

Code:
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
    // initialize the remainder veriable
    int remain = 0;
   
    // initialize the denominator
    int denom = 0;
   
    // imput the values for remain and denom
    cout << "Enter a numerator: ";
    cin  >> remain;
    cout << "Enter a denominator: ";
    cin  >> denom;
   
    // initialize the incrament veriable used for the loop
    int i = 2;
   
    while (true)
    {
        for ( ; denom % i == 0 ; )
        {
              if (remain % i == 0)
              {
                  break;
              }
       
              else
              {
                  i = i + 1;
                  continue;
              }
        }
    }
   
    // divide the remainders by the greatest common
    // factore and assign them to the Show veriables
    int remainShow = remain / i;
    int denomShow = denom / i;
   
    // display the results
    cout << "The simplified fraction is: "
        << remainShow
        << "/"
        << denomShow
        << ".\n";
   
    // wait until user is ready before terminating program
    // to allow the user to see the program results
    system("PAUSE");
    return 0;
}

When I enter the second number, it just stops working. Any idea what's wrong?

If you want to see for yourself, you can download the .exe here.

_________________
My Journy Into Programming Bzsigy2
CivBase
CivBase
Adbot

Male Number of posts : 7336
Location : Etchisketchistan
Registration date : 2008-04-27

http://pathwaygames.forumotion.net/

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by L0d3x on Thu Feb 19, 2009 5:59 am

What's up with that weird loop? The problem you are getting is that you get stuck in an infinite loop. The while(true) will ALWAYS keep repeating the for loop inside. The break statement you use in the for loop will ONLY break out of the for loop, not the overhead while loop.

Try the following instead of the while and for loop, also remove the first i = 2 statement (the one just before your while loop started):

for (int i = 2 ; denom % i == 0 ; i++)
{
if (remain % i == 0)
{
break;
}
}

Let me know if that works.

L0d3x
Minion

Male Number of posts : 162
Registration date : 2009-01-10

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by CivBase on Thu Feb 19, 2009 6:35 am

Well, it worked... sort of. I complied it and here's what I got.

Code:
Enter a numerator: 10
Enter a denominator: 15
The simplified fraction is: 5/7.
Press any key to continue . . .

*goes back to scan through the program several times until I can figure out what's wrong*

You know... now that I think of it... why did I decide to use an infinite loop?

EDIT:

I think I figured out what's wrong.

First, it declares the i veriable and sets it equal to 2. Then it checks to see if denom % i == 0. Then it checks to see if remain % 1 == 0. Then, if neither of those work, it incraments i and restarts. Problem is, if remain % i == 0, then it breaks (even if denom % i is not zero). Am I right?

I'll keep working on it.

EDIT AGAIN:

So I changed it to this:

Code:
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main(int nNumberofArgs, char* pszArgs[])
{
    // initialize the remainder veriable
    int remain = 0;
   
    // initialize the denominator
    int denom = 0;
   
    // imput the values for remain and denom
    cout << "Enter a numerator: ";
    cin  >> remain;
    cout << "Enter a denominator: ";
    cin  >> denom;
   
    int i = 2;
   
    for (; ;)
    {
        if (denom % i == 0)
        {
              i = i + 1;
              continue;
        }
       
        if (remain % i == 0)
        {
              break;
        }
    }
   
    // divide the remainders by the greatest common
    // factore and assign them to the Show veriables
    int remainShow = remain / i;
    int denomShow = denom / i;
   
    // display the results
    cout << "The simplified fraction is: "
        << remainShow
        << "/"
        << denomShow
        << ".\n";
   
    // wait until user is ready before terminating program
    // to allow the user to see the program results
    system("PAUSE");
    return 0;
}

It still spits out the wrong fraction though... Sad

EDIT AGAIN AGAIN:

And ithe same problem from before happens when I enter 2/4. In fact, it does that with every fraction I enter that should be 1/2.

_________________
My Journy Into Programming Bzsigy2
CivBase
CivBase
Adbot

Male Number of posts : 7336
Location : Etchisketchistan
Registration date : 2008-04-27

http://pathwaygames.forumotion.net/

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by L0d3x on Thu Feb 19, 2009 8:58 am

Hmm I didn't examine your algorithm, and don't really feel like going through it.
But there's a very common method used for calculating the GCD, I think it's called Euler's algorithm or something and it's really easy to implement.

I suggest you use that one. Wikipedia should give you the stuff you need.

L0d3x
Minion

Male Number of posts : 162
Registration date : 2009-01-10

Back to top Go down

My Journy Into Programming Empty Re: My Journy Into Programming

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum