programming exercises

Sep 4, 2010 at 2:24pm
hello, does any one know where i can find some good c++ programming exercises. I'm looking for some fairly difficult exercises (but not impossibly difficult?). Or perhaps there is a book which is known for it's exercises?.


Sep 4, 2010 at 2:28pm
Try these: http://www.cplusplus.com/forum/articles/12974/
They are quite easy but they are sorted by difficulty level so you can try the last few
Sep 4, 2010 at 2:29pm
Here you go: http://cplusplus.com/forum/articles/12974/
These range from very easy to moderately difficult. Once you've done those, you can do them again but in a more complex way. As an example, you could make a better TUI with ncurses, then make that into a GUI with Qt, make a client-server architecture (client takes input from user, server processes it and sends the results to the client to be output) or find some other way to complicate it.

You can also do these mathematical exercises: http://projecteuler.net/

Edit:
@Bazzy
FFFFFFFFFFFFFFFFFFFFFFUUUUUUUUUUUUUUUUUUUUUUU
Last edited on Sep 4, 2010 at 2:30pm
Sep 4, 2010 at 2:33pm
(but not impossibly difficult?)

Take a calculator for the computing the following:

y=(a+b)/(a-b);

Give it a name in english if you like.
Record each step giving a name.
The rest is what you are looking for.
Sep 4, 2010 at 3:23pm
We'll call it Chrisname's Sequence.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
def f(a, b):
        return (a + b) / (a - b)

for a in range(0, 4):
        for b in range(5, 9):
                a = float(a)
                b = float(b)
                print("y = f(%d, %d) = %f" % (a, b, f(a, b)))
y = f(0, 6) = -1.000000
y = f(0, 7) = -1.000000
y = f(0, 8) = -1.000000
y = f(1, 5) = -1.500000
y = f(1, 6) = -1.400000
y = f(1, 7) = -1.333333
y = f(1, 8) = -1.285714
y = f(2, 5) = -2.333333
y = f(2, 6) = -2.000000
y = f(2, 7) = -1.800000
y = f(2, 8) = -1.666667
y = f(3, 5) = -4.000000
y = f(3, 6) = -3.000000
y = f(3, 7) = -2.500000
y = f(3, 8) = -2.200000


It's not a very interesting sequence really.
Last edited on Sep 4, 2010 at 3:32pm
Sep 4, 2010 at 4:43pm
Look at this:
1
2
3
4
5
#include <iostream>
int main()
{
    std::cout <<  "y " << char ( ('a' + 'b') / ('a' - 'b') ) << " ( a + b ) / ( a - b )\n";
}
y = ( a + b ) / ( a - b )

Topic archived. No new replies allowed.