Question

I've been asked to tutor Pascal to a kid. Despite never seen Pascal before I did manage to get a tutorial and I now know enough to teach him.

I am writing you guys to see if anyone can point me out some basic exercises that involve simple algorithms, Something like: Sort this array, find the average, etc...

It can be in any language, I just need to find some exercises so he can work out.

Was it helpful?

Solution

Here is a list of 15 Exercises for Learning a new Programming Language from freelance that expands on basic techniques used in many languages and can give him a feel of the new lanaguage he's learning

OTHER TIPS

I am going to address this in a (mostly) language-agnostic fashion. After teaching him print statements and flow control (if statements, for loops, etc.), my suggestion would be to start off with simple ASCII-art patterns that can be generated by for loops and such.

For example, how would you print half of a tree, like this?

*
**
***
****
*****
******

Alright, now how would you print a full tree, like this?

     *
    ***
   *****
  *******
 *********
***********

Now try drawing a rocket ship. ;)

These are great for most kids because they are visual, the results are enticing, and the exercises will impart the importance of loops and eliminating redundancy.

For sorting algorithms see link. It is a Wikipedia article - a little general information on sorting algorithms, but down below you have links to every type of them individually, and algorithms in pseudo code (and some languages).

As far as "find the average" goes, when you've got "n" elements:

SUM=0.
DO i=1,n
 SUM=SUM+element(i)
ENDDO
AVRG=SUM/n

Also, for learning purposes and thinking Project Euler is very nice.


Also, do take a look at this question: Where can you find fun/educational programming challenges? I didn't want to copy paste everything, but it has a bunch of links with stuff for exactly what you're looking for (programming exercices). And this: Algorithm Questions Website, What are your programming exercises?. You'll probably find something you think he'll be interested in in there.

classic one:
Let the program choose a random number, the purpose of the game is to find the number through elimination. if the user guesses a lower number the program says its too low, if its higher it says its too high.

Tic tac toe game with "AI" (that is predefined moves) and text-graphics is a nice project.

Add some fun to it. A good one to start with:

Paper-Rock-Scissor Game

User enters P, R, or S

Program responds that you win, lose, or tie

More advanced features: track record, winning %, win/loss streak

Doing basic operations on a doubly linked list is also a classic.

If you know any C/C-like language it's basically the same:

  • { } are begin end;
  • == is =
  • = is :=
  • a function that returns nothing is a procedure.
  • a function that returns something is still a function.
  • int is Integer.

The rest is almost the same. The syntax is a bit different, but not very different.

You would need to know which Pascal they're using, and what they taught them to be sure you're not wasting your/his/her time.

Early exercises I learned from include drawing the Mandelbrot set (computers are much faster these days so you don't immediately have to worry so much about optimization) and implementing cellular automata like the Game of Life.

Of course, if this is practice for a school course, exercises like this will only be helpful if the test is likely to test a similar domain of knowledge/skills.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top