LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-25-2005, 09:35 PM   #1
microsoft/linux
Senior Member
 
Registered: May 2004
Location: Sebec, ME, USA
Distribution: Debian Etch, Windows XP Home, FreeBSD
Posts: 1,445
Blog Entries: 9

Rep: Reputation: 48
Suggestions for beginner's project?


Does anyone care to offer a suggestion on a project for a beginning programmer. I did a project for science fair that took the input temperature from another program, and converted the output to kelvin. I since returned the sensor, or I would ahve kept working on that. That program was written in C++, and that's the language I would like to continue in. Any suggestions?
 
Old 06-25-2005, 10:21 PM   #2
titanium_geek
Senior Member
 
Registered: May 2002
Location: Horsham Australia
Distribution: elementary os 5.1
Posts: 2,479

Rep: Reputation: 50
how about a program that generates good ideas for beginners?
*apologies. late night cynisism*

ok, how about (and I really apreciated this as a learning exercise)
a program that take a given number of things, shuffles them, and returns the result? have you seen those nine letter newspaper problems?

anyway, its late, I'm going to bed now because I can no longer type...

umm... a program to find prime numbers? calculate pi?

titanium_geek
 
Old 06-25-2005, 10:45 PM   #3
microsoft/linux
Senior Member
 
Registered: May 2004
Location: Sebec, ME, USA
Distribution: Debian Etch, Windows XP Home, FreeBSD
Posts: 1,445

Original Poster
Blog Entries: 9

Rep: Reputation: 48
thanks for the ideas. I kinda like the prime numbers one, that would'nt necesarily be a hard program. However, it would be extremely CPU intensive I believe. Again, thanks, other thoughts?
 
Old 06-25-2005, 11:40 PM   #4
lowpro2k3
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
These helped me get better at C++ and were the first 'real' pieces of code that really made me think on my own. I had basically read most chapters from an intro C++ book (C++ Primer Plus) and done most excercises. The best 'project' you can do is to read and write alot of code, and work your way through a good textbook over the course of a month to sharpen your general language skills. It might be dry at times, but its worth it, and the programs you write will be much less trivial when your finished.

If you have a good understanding of classes but havent written anything 'real' yet, besides maybe the Time, Shapes or Employee classes that many beginners learn, these are a good place to start.

Classes
* Write a string class, from which you can create strings. Overload some common operators, like +, +=, =, == and ensure correct memory management is implemented.

* Get a deeper understanding of C++ classes and Object Oriented Programming from reading a bit. Read a fair amount about pointers and write your own Linked List class. Some common methods you might want to implement would be front/rear insertions and deletions, length checking, and after those are done, implement insertion/deletion anywhere in the list. Research effective algorithms for searching and sorting lists, and try and implement a few. You should have a good enough understanding to use the STL <list> class, compare it to your class, and use the <list> class in some real-world programs.

* Write an array class, similiar to the string class. You might want to do a few things with it - overload assignment operator, perform bounds checking, overload [] operator, etc...

* If Lists are easy, try writing an abstract Tree class, and inherit a binary tree class from this.



If these are a little much, read about the following topics and write lots of code using them in C++: pointers, functions, arrays, classes, advanced classes (inheritance, polymorphism), templates and data structures.
 
Old 06-25-2005, 11:57 PM   #5
shakezilla
Member
 
Registered: Jun 2005
Location: U.S.
Distribution: xubuntu 8.10, linux 2.6.27-11-generic
Posts: 78

Rep: Reputation: 16
First let me say, good choice to be learning with c++.

Now don't misunderstand, I'm not knocking any other languages, but
c++ is good to learn with because it teaches you many fundamentals
that a lot of other languages (java, 3 p's, c#) just don't.
  • This is a short program I did in CS 1. Write a program to take a total ($3.68),
    and a tendered amount ($5.00), and output the change in english.
    So something like this:
    -----------------------------
    Total: $3.68, Tendered: $5.00
    Change: 1 dollar, 1 quarter, 1 nickel, and 2 pennies
    -----------------------------
    See if you can extend it to handle all the denominations from penny up to benjamin,
    or whatever currency they use wherever you're from. Notice to get the commas
    and the 'and' in the right place, you'll have to remember your position. Arrays
    can help you do this easily, if you can see how to do it.
    -----------------------------------------------------------
  • Yes, classes are great to make you a good c++ designer. Make a set
    class (as in a mathematical set). Have functions and corresponding operators
    for union, intersection, complement. You'll find that set classes are useful
    in many of the algorithms you use in computer science.
    -----------------------------------------------------------
  • You know how when you play final fantasy (>=8) and you can tell the airship to
    auto navigate to a place on the map? Write a program to figure out that.
    In other words, assuming the planet is a perfect sphere, and given the
    current position, the destination, and the direction the ship is currently facing,
    make the program output the degrees the ship should rotate and then the
    distance it should travel to get to the destination. The units you use for each
    part really don't matter as long as you're consistent.

    Hint: shortest distance between 2 points is a straight line, right? So find the
    line between them (this will be straight thru the planet). Then follow that line
    over the planet's surface. CAREFUL: If you're at the North Pole and trying to
    get to the South Pole, you'll have to choose arbitrarily.
    -----------------------------------------------------------
  • Euclidean algorithm: this finds the gcd of 2 integers, google it.

    Extended Euclidean algorithm (google that also):
    does the same thing but also finds two other integers as well.
    If you read some of those links, understand them, and write
    a program to calculate them, then you'll understand part of the basis for RSA.
    If you don't know, RSA is what make internet security such as credit
    card transactions and secure logins work.

EDIT: added another item

Last edited by shakezilla; 06-26-2005 at 12:06 AM.
 
Old 06-26-2005, 09:12 AM   #6
microsoft/linux
Senior Member
 
Registered: May 2004
Location: Sebec, ME, USA
Distribution: Debian Etch, Windows XP Home, FreeBSD
Posts: 1,445

Original Poster
Blog Entries: 9

Rep: Reputation: 48
actually, I've never played final fantasy n. Thanks for all the ideas. Most of those, I don't even have an inkling where to start. Other thoughts? I like the ideas for a high level math program(e.g. prime numbers, pi, Euclidean Algorithm) Thanks again
 
Old 06-26-2005, 09:53 AM   #7
microsoft/linux
Senior Member
 
Registered: May 2004
Location: Sebec, ME, USA
Distribution: Debian Etch, Windows XP Home, FreeBSD
Posts: 1,445

Original Poster
Blog Entries: 9

Rep: Reputation: 48
I've been googling the euclidean algorithm. I somewhat understand it, but not completely. Do you know of a good site that would explain it? Thanks again.
 
Old 06-26-2005, 01:47 PM   #8
shakezilla
Member
 
Registered: Jun 2005
Location: U.S.
Distribution: xubuntu 8.10, linux 2.6.27-11-generic
Posts: 78

Rep: Reputation: 16
Warning: do Euclidean and primes (Sieve of Eratosthenes) before you try
to do pi and the airship problem.

Do you at least know the process of Euclidean algorithm?

Never played ff? Ok, imagine you were going to fly a plane (in a straight line,
non-stop) from Maine to say, St. Petersburg, which is roughly in central Russia,
I believe. Faster to go across the Atlantic, or Pacific?

Well, in this case, probably the Atlantic, but how would you be sure? Probably
the Gobi desert (in Central Asia) is an even better example, although not very
practicle.

I'll try to get back to you on Euclid.
 
Old 06-26-2005, 03:19 PM   #9
lowpro2k3
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
Use the <cstdlib> file and use the rand() function to generate random numbers. Create a huge array (or file, or vector, or list if you want), say about 10,000 elements long, and write a loop to fill it with random numbers.

Research some sorting algorithms (start with the bubble sort, its probably easiest) and sort your list into order. Try and visualize on paper and in your head what's happening in memory.

Example:

Say you have an array that looks like this:

59 | 603 | 31 | 792 | 116 | 8

This example array is 6 elements long. Using a bubble sort, we work our way from left to right, comparing the current element, with current element + 1, and swap the elements if right side is less than left. I wont write the whole loop(s) for you, but I'll give you an idea of the first 3 passes through the array. The idea is the smallest numbers "bubble" their way to the top of the array, this algorithm is quite slow compared to other search algorithms, but its a fun one to work out.

Code:
Original Array
59 | 603 | 31 | 792 | 116 | 8


Pass One

603 < 59 ? no
31 < 603 ? yes, swap - 59 | 31 | 603 ...
792 < 603 ? no
116 < 792 ? yes, swap - 59 | 31 | 603 | 116 | 792 ...
8 < 792 ? yes, swap - 59 | 31 | 603 | 116 | 8 | 792

After first pass
59 | 31 | 603 | 116 | 8 | 792

Pass Two

31 < 59 ? yes, swap - 31 | 59 | 603 | 116 | 8 | 792
603 < 59 ? no
116 < 603 ? yes swap - 31 | 59 | 116 | 603 | 792
8 < 603 ? yes swap - 31 | 59 | 116 | 8 | 603 | 792
603 < 792 ? no

After second pass
31 | 59 | 116 | 8 | 603 | 792
Now you see we're almost in order, but we still need 4 more passes to "bubble" 8 to the top of the array. Try it on paper, you'll see what I mean. Each successive pass from now forward will move 8 "up" one more element.

If you understand this well, ask yourself - after the "bottom" elements have been put into order, do we need to do the comparison every time? Can you think of a better way to slightly optimize this algorithm? Figure out the core part first, then come back and try the little optimization trick.

Last edited by lowpro2k3; 06-26-2005 at 03:27 PM.
 
Old 06-26-2005, 04:13 PM   #10
microsoft/linux
Senior Member
 
Registered: May 2004
Location: Sebec, ME, USA
Distribution: Debian Etch, Windows XP Home, FreeBSD
Posts: 1,445

Original Poster
Blog Entries: 9

Rep: Reputation: 48
I see. I get the basic premise behind the eulicdean algorithm, I also understood the basic premise on the airship thing. How much programming experiance should I have for each of these projects. Like I said, I've done one project. My project basically took the input from a file(where the temperature was recorded in degrees fahrenheit by another program. I adapted that program so it ran once, and I could do a system call inside my loop), and converted the temperature in kelvin, and printed it to the screen. Other thoughts?
 
Old 06-26-2005, 10:27 PM   #11
shakezilla
Member
 
Registered: Jun 2005
Location: U.S.
Distribution: xubuntu 8.10, linux 2.6.27-11-generic
Posts: 78

Rep: Reputation: 16
Go ahead and try to do Euclidean. Write a program to take in 2
values and output their gcd (and LCM for extra), and maybe even
the other 2 values you end up with by doing the extended algorithm.

Go on to arrays if you haven't yet, then classes.

Like lowpro2k3 said, do some searching and sort programs. Here
are the things you'll want to google for:
binary search
bubble sort
selection sort
quick sort

Keep designing until you feel comfortable with arrays and functions.

Recursion is something you may want to look into, you can try doing
the classic factorial and fibonacci examples with recursion (careful,
start out with small numbers). Start with the factorial, and move on
to the fibonacci, it shows you why recursion isn't always the best way.

Another good thing to try with recursion are maze problems. That can
introduce you to depth first and breadth first searches.

Now do the airship problem.

This one is a lot more advanced, so save it til you're very comfortable.
It is an excellent exercise which will teach very much about arrays,
dynamic memory, classes, operator overloading, and inheritance:
Write classes to implement vectors and matrices (matrix) in c++. Give
them the 4 basic ops (+ - * /) for both scalars and other objects of
their own class type. If that's too easy for you, add functions to get and
set the vectors' values as polar or spherical coordinates, or to do
Guassian Elimination on a matrix.
Like I said, wait a while on that. The reason I mention it to you even
though you're just starting is because it teaches you so many things.

Maybe after all that, you're ready to move on to linked data structures.
These would be things like trees, graphs, stuff like that.

Don't get discouraged, if (when) you get stuck, just slow down, and remember:
Understanding the algorithm is more important than knowing any one
particular language (maybe not when it comes to the job market, but....).

btw, if you're confused about any of the math terms I mentioned here is
a great place to look it up:
http://mathworld.wolfram.com/
Their pages are a little on the technical side, but very informative.
 
Old 06-28-2005, 10:12 PM   #12
microsoft/linux
Senior Member
 
Registered: May 2004
Location: Sebec, ME, USA
Distribution: Debian Etch, Windows XP Home, FreeBSD
Posts: 1,445

Original Poster
Blog Entries: 9

Rep: Reputation: 48
anyone else have any ideas? Thanks for all the suggestions.
 
Old 06-29-2005, 07:33 AM   #13
NCC-1701&NCC-1701-D
Member
 
Registered: May 2005
Distribution: Debian Woody,Knoppix
Posts: 88

Rep: Reputation: 16
Why don't you write a program wich calculates the ö (fi)number in some object (eg.black hole). You could also write an app which calculates in % how slower would be time in an moving reference system(the Einstein-Lorentz equation). I'm currently writing an physics app,both in C and C++ to compare their speed.It gets as input (in kilotons)the power of a nuclear fission reaction,get's an amount of water(in kg) and calculates how much would this amount of water be heated (in Celsius and Kelvin) from this reaction.
 
Old 06-29-2005, 01:34 PM   #14
orgcandman
Member
 
Registered: May 2002
Location: new hampshire
Distribution: Fedora, RHEL
Posts: 600

Rep: Reputation: 110Reputation: 110
although interesting, mathematics problems aren't usually very informative after fib, et. al.

Probably some great things to do would be to design and implement a stream tokenizer. Maybe a pattern matching program. How about a base HTTP server (won't read/write files, just always returns a 404)? They're not that difficult, and are great learning tools.

-Aaron
 
Old 06-29-2005, 04:32 PM   #15
microsoft/linux
Senior Member
 
Registered: May 2004
Location: Sebec, ME, USA
Distribution: Debian Etch, Windows XP Home, FreeBSD
Posts: 1,445

Original Poster
Blog Entries: 9

Rep: Reputation: 48
what in the world is a stream tokenizer? I'd like to get a better grasp on programming before I try an HTTP server. Thanks again for all the ideas. Other thoughts?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu beginner's guide Tsukasa7 Ubuntu 3 09-02-2005 01:25 AM
Beginner's Questions Re Fedora, Core 2 LinuxLearning Linux - Newbie 4 10-27-2004 01:16 PM
portable programming - any suggestions for kicking off a project? PBSchmidt Programming 2 09-03-2004 02:57 PM
Beginner's question on partitioning boeben Fedora 4 03-18-2004 06:23 PM
Request for honors project suggestions mrtwice Linux - General 1 06-05-2002 12:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration