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 !!
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...
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