Thursday, September 22, 2005

STRUCTURE OF A GOOD 'C/C++' PROGRAM

There are certain basic aspects that should be kept in mind; such as the format of the code, indentation, comments, smart variables etc..

As for the basic layout, here is a tip:

1> Documentation:

This should contain the objective of the program, the creator's name and date if neccessary and other details about the program. It should be in the form of a multi-line comment.

Example: /* Program to add two numbers.
created on: 22 sept-2005, by:urjit */

2>Linking of files and Inclusion:


This section should be used to link to all header files, external files and the library functions. Macros could also be placed in this section.

Example: #include
#include
define PI 3.14

3>Main program:


This section should ideally contain the classes (in case of C++), global variables, filestreams, and the body of the main( ) function, containing all the sub-functions, local variables, objects etc..



4>Functions and extra comments:


This section should contain the extra information and notes about debugging if required (untill the code is perfected), other functions that are to be used in the main program (for defining the functions here, they have to be declared above their control entry; i.e., generally above main).



Example:
/*program to add two numbers. created by:xuxux created on: 30/6/05 */








3 Comments:

At 9:48 PM, Blogger lennybrinick08864343 said...

I really enjoyed your blog. This is a cool Website Check it out now by Clicking Here . I know that you will find this WebSite Very Interesting Every one wants a Free LapTop Computer!

 
At 10:45 AM, Blogger Wealthy from the internet said...

Hi URJIT,

Do you want to be VERY succesfull?

You will be dominating any market within days with our blog advertisement !

I only worked 1,5 months with this blog advertisement and it improved my Page rank, web site traffic and also enlargened my income by 2000%!

Try this, you will be happy you had a look!

Regards and lots of money!

http://www.superblogsubmitter.com

Isn't it time for you to get blog advertisement

Newest and most innovative blog advertisement

 
At 9:41 AM, Blogger Juan more ? said...

Urjit,

I am a C++ student taking my first programming class. Do you ever help people when they are stuck?

Juan

 

Post a Comment

<< Home