Some general guidelines while attempting the problems for beginners or those who have just started programming:

* The use of all non standard headers and functions is discouraged. Implement the problem with only standard C / C++ functions. A list of standard C / C++ functions and headers can be found here.

* Don't use system("pause") to pause your program if possible. Use getchar( ) if you are using C and cin.get( ) if you are using C++.

* The prototype of the entry point of the program i.e. the main function is int main( void ). Anything else is non standard and incorrect. See here for explanation.

* If possible stay away from using scanf( ) for accepting input from the user. The fgets( ) and sscanf( ) combination works the best here. It also gives you more control over the way you interpret and analyse the user input. For a detailed tutorial look here.

* Try giving meaningful names to the variables you use. Though it may seem like a *lot* of work using names like 'my_string' when 'a' seems to be doing the job pretty well, it would save you from a lot of head banging in the future specially when you can tell what a varaible is meant to do in a program just by looking at its name.

* If possible do initialize variables when you declare them -- especially pointers. It would save you from a lot of trouble when you variables start returning junk values and you have no idea where they came from.

* After you are done with pointers in your program, don't forget to ground them (set them to NULL) to prevent their inadvertent use after they have lost their meaning or outside their context. This will definately save you from pulling your hair out when the program becomes large and accessing stray pointers would only result in hard to find bugs.

* Don't forget to check for return values of functions. Even though it may look to you that the function would never fail, if they do, there sure would be some obscure, hard to find bugs. One classic eg. is checking for return value of the malloc function which returns NULL if allocation fails. Ditto for fopen( ).





Keywords: C / C++ FAQ's,Practice problems,general guidelines ,using C++.,values of functions