No Exercises here on the website !!

As all of us see , this site offers a great tutorial for beginners but no exercises (I really suffer from as a beginner ) .
I believe in learning by practice , So what do u think about writing Exercises & its answers for each topic or part of the tutorial ??
CMinus
Learn new thing every moment !!
closed account (10oTURfi)
http://www.cplusplus.com/forum/articles/12974/
Here are a couple more:

Exercise I
------------


Requires knowledge of: functions

Write a function taking 5 int arguments and returning a bool.
bool are_sides_and_diagonal( int a, int b, int c, int d, int e ) ;

The five arguments are the lengths of five straight line segments.

The function should return true if it is possible to form a quadrilateral of which the sides are any four of the arguments and the remaining one argument is a diagonal. Otherwise, it should return false.

Example: With the arguments 1, 2, 3, 4, 5 no such quadrilateral can be formed. Return false.

Example: With the arguments 2, 3, 4, 5, 6 such a quadrilateral can be formed (with sides 2,3,5,6 and 4 as a diagonal). Return true.



Exercise II
-------------


Requires knowledge of: functions, arrays (or rudiments of std::vector<>)
Note: does not require knowledge of dynamic storage duration.

Define the integer function F(x) as the sum of the squares of the digits of x.
Example: F(3) = 3*3 = 9 and F(230) = 2*2 + 3*3 + 0*0 = 13.

Define the set S(x) to be the set of (unique) numbers that are produced by repeatedly applying F to x. ie: F(x), F( F(x) ), F( F( F(x) ) ), etc...

Example: Repeatedly applying F to 37, we get:
F(37) = 3*3 + 7*7 = 58
F(58) = 5*5 + 8*8 = 89
F(89) = 145
F(145) = 42
F(42) = 20
F(20) = 4
F(4) = 16
F(16) = 37


This sequence will now repeat; so we can stop and:
S(37) = { 58, 89, 145, 42, 20, 4, 16, 37 }.
Note that S(x) need not necessarily contain x.

Implement a function int smallest_member( int x ) ;
taking int x as the input, and returning the smallest integer in S(x) as the result.
Assume that x is in the range 0 <= x <= 99

Example: smallest_member(37) should return 4.
Last edited on
closed account (1yR4jE8b)
http://projecteuler.net/

http://codercharts.com/
Topic archived. No new replies allowed.