I asked a friend for some small code sample ideas to be written in C. I haven't used C in years, but I still apparently can.

Sample code in c/c++

This was a fast worked example, written with an eye for reasonable performance and short dev time.
Due to the fact I was writing C for the first time on this box, I needed to setup the development environment and I was dealing with emails etc, this took me ages.

Specification (file 1)

The source is here
int CountNumerals(const char *str);
Check every character in the string and return how many of those are numeric (i.e. 0-9).

Specification (file 2)

The source is here
int FindMostCommon(const int *numbers ,const int count);
Given a series of numbers, find the one that is most common. For the purpose of this test, you can assume that one of them IS more common. i.e, given the following numbers
1,7,3,7,2,3,9,7 you would return 7 because it happens 3 times..

Versioning (same for each)

I only needed to resolve a few typos, to make it compile. I have added no extra features bar the test cases. These are quite simple.

  1. [0.2.0] This code you see.
  2. [0.0.1] This code and the test cases.
  3. [0.0.2] This code you see and commenting, this was the edition I released.

References

None, this is pure numerical computation.


Some numerical example code

RSS. Share: Share this resource on your twitter account. Share this resource on your linked-in account. G+

Some numerical example code

RSS. Share: Share this resource on your linked-in account. Share this resource on your twitter account. G+ ­ Follow edited