Forum: Geek Forum
Topic: C programming exercise
started by: LiNeY

Posted by LiNeY on Oct. 24 2001,19:26
As posted before, I started teaching myself programming C. I love it, and it's real fun... I got as far as pointers, and I think I even understood what they're about. However, I haven't been doing anything in the last weeks, because I didn't have anything useful to do. I mean... I could write simple (very simple!) programs, if I knew what to write a program about. I need tasks, or exercises, or challenges, or whatever.

Do any of you guys have an idea what I could do? It shouldn't be too difficult (remember I'm a blonde) and cover the basic use of C. I'd be glad about suggestions and ideas... my brain and my compiler are yearning for some action!

------------------
C'est à cette amie que je me confie - mais c'est l'autre que j'embrasse...


Posted by chmod on Oct. 24 2001,19:36
Once you've got pointers down, you might wanna explore data structures a bit - linked lists, binary trees, etc... They are a pain in the ass but you can learn a lot by playing with them.
What platform do you do all your coding on?
Posted by DeadAnztac on Oct. 24 2001,19:38
I could pass along some of the assignments we're doing in Computer Science, and if you don't know how to do something, that's cool, we can work it out It's certainly not hard for me (I half teach the class at the moment). Whaddya say? It's something to do

------------------
~Anztac [ Pertinaciously disconsolate ]


Posted by CowboyNeal on Oct. 24 2001,20:14
Yeah, I could use some exercise...but then I just go see what's on the television..

------------------
I'm a bad little cowboy and I like it.*

*by little i mean huge**

**and by Cowboy I mean fat-ass


Posted by TallAssAzn on Oct. 24 2001,21:25
I suppose I'll be checking up on this thread too...

<-- needs to learn C, but has no time. HS Sopho. w/ 2x AP classes... Yeah.

------------------
<º(((><


Posted by chmod on Oct. 24 2001,21:31
Shit man, I've got 6 AP classes. It actually hasn't been that bad.... yet. But AP computer science is a joke, fortunately the teacher is open-minded enough to let me work on my own stuff. I would insert a rant about that course somewhere, but it seems Chase has already done so. hmph.
Anyways... here's an interesting quiz on C you might wanna try, for shits and giggles: < http://www.cprogramming.com/cgi-bin/quiz.cgi >

Posted by damien_s_lucifer on Oct. 25 2001,02:19
liney - think of something that needs a simple database - a personal phone book or something. Then implement a B-tree and use it to hold your data. That will teach you a lot about two of the most useful programming topics, pointers and recursion.

If you're interested let me know & I'll type up one of my famous Lectures detailing how a B-tree works.

You have to email me a picture of you though

Question #2
Which of the following is evaluated first:
a) &&
b) | |
c) !

My answer : Probably ! because it's a unary operator. But who the fuck cares? Real programmers don't bother memorizing operator precedence. They just parenthesize everything


Posted by @$$h0l3 on Oct. 25 2001,03:31
If you want something that will teach you more about designing an algorithm than coding, try the towers of Hannoy (sp?) problem. Properly implemented, it should only be a handful of lines, but you must think long and hard before you code to get the recursion right (at least when you are starting to code).

The problem: You have three pegs, two are empty, and one has x number of disks stacked on it. The disks are stacked with the largest disk on the bottom and the smallest on top. You goal is to move all the disks from one peg to another, but there are rules.
1) you can only move one disk at time.
2)you cannot put a larger disk on top of a smaller one.
Sometimes there's a third rule, but I don't remember it.

I believe when I took <don't laugh> Pascal </don't laugh> back in the old days, the completed program was ~ 20 lines long, including variable declarations, begin..end statements and the main program. But it took me a while to figure it out, and it's a very tidy exercise in recursion. When you see it in your head for like x=64 rings, it's quite cool.


Posted by LiNeY on Oct. 25 2001,15:18
quote:
Originally posted by damien_s_lucifer:
If you're interested let me know & I'll type up one of my famous Lectures detailing how a B-tree works.

You have to email me a picture of you though

Question #2
Which of the following is evaluated first:
a) &&
b) | |
c) !

My answer : Probably ! because it's a unary operator. But who the fuck cares? Real programmers don't bother memorizing operator precedence. They just parenthesize everything


My answer: Probably ! because it's unary, but who the fuck cares? Real women don't bother memorizing operator precendence. They copy the table listing all of 'em in order out of the book and keep it handy!

I'd love to get that lecture about the B-Tree. If you email it to me, I'll send you a pic in return.

Oh and btw guys... can anyone help me with this little problem? I have never written programs which store data or make files or something, i.e. as soon as I close the program, everything's gone... What do I have to do?

It sucks to be a lam0r... a blonde lam0r...

------------------
C'est à cette amie que je me confie - mais c'est l'autre que j'embrasse...


Posted by damien_s_lucifer on Oct. 25 2001,19:37
LiNeY - you need to store your data in a file. Any good C book should have a section on reading in / writing out files.

File I/O is pretty simple... basically you use functions that work exactly like printf() and scanf() except they take another argument called a filehandle so they know which file you're talking about

Maybe we should start with file I/O before getting into B-trees. B-trees aren't all that interesting if you can't read and write files.

Also, what OS are you programming in?

This message has been edited by damien_s_lucifer on October 26, 2001 at 02:38 PM


Posted by Beldurin on Oct. 26 2001,02:05
quote:
Originally posted by @$$h0l3:
If you want something that will teach you more about designing an algorithm than coding, try the towers of Hannoy (sp?) problem.


1. It's spelled Hannoi, I think and
2. I had to write that bitch in ASSEMBLER

Talk about a nightmare...

As for things to write, way back in the day when I was taking C++ classes we had to write things like a maze game, a classroom reseveration program, and for my wonderful Assembler class, I had to write an assembler in C++...I think I still have all my source code zipped up on a backup disk if you want any of it.

------------------
Give me ambiguity or give me something else...


Posted by LiNeY on Oct. 26 2001,08:51
quote:
Originally posted by damien_s_lucifer:
Also, what OS are you programming in?

Microsoft Millenium Edition, also known as the evil MS ME. I'd rather use Linux but I don't know enough about computers yet, and everyone around me uses MS, so it's easier... I must say that ME bugs less with me than it does with most people. I still don't like it much.

And my compiler is also an evil MS thingie. Microsoft Visual C++ 5.0... I got it from a friend but he doesn't work with it himself (clever guy), so I have nowhere to turn to with questions.

------------------
Je t'aime... moi non plus


Posted by miNus on Oct. 26 2001,10:42
I use Visual C++ too. It's not bad, though, I've never really gone and tried to use anything else...

I'm probably at about the stage Liney is at, maybe even a bit below. I took a class in high school and it taught me the basics and I was teaching myself for a while, but once I got to pointers I just kind of stopped.

Anyway, a little OT:
Liney, you should switch OS's from the Evil ME, to the slightly lesser evil (the diet coke of evil, only 1 calorie, not evil enough!) Windows 2000. It's alot more stable and then you can start to learn how a real network OS works (and if you install 2000 server for some odd reason, you can play with active directory! Yay!). Speaking of AD, I have to install a just-for-fun server sometime soon so I can sit down and fiddle with it.


Posted by Beldurin on Oct. 26 2001,14:24
With Visual C++ are you writing actual windoze proggies with the MFC's or are you writing console apps? (which is what I mostly did)

My first C++ class and most of my assembler class were done in vi on a solaris box, but my others (advanced C++, data structures, and java) were done using GUI environments. I personally think that the UNIX one is MUCH cleaner (no namespaces, etc), but if you're writing windowed apps, there's not much you can do about that, is there?

As for the ME vs. 2K, I'm w/miNus on this one (p.s. just set up 2 2K servers for my dept. @ school DCHP, Proxy, IIS 5 MSSQL 7...fun stuff!)

------------------
Give me ambiguity or give me something else...


Powered by Ikonboard 3.1.4 © 2006 Ikonboard