HOME            LINKS
Example for the structure and naming conventions.

Let's discuss a small basic example for naming conventions and structuring of the program. This is a small code snippet written in C.

(Without any structure, naming conventions and comments)

#include <stdio.h>

int main(void){int a;int b;int c;int i;
a=0;b=1;c=1;i=1;
for(i=1;i<=10;i++){a=b;b=c;c=a+b;printf("%d",a);}}

Above program will compile and run successfully but the thing is, if you give it to the other user to modify or understand then it will be very difficult for him/her. This one is really very small example but we have to think for the big programs where some thousand kilo lines of code is available.

Let's modify it in a way that it looks in following way.

#include <stdio.h>

int main(void)
{
     int prev;
     int cur;
     int next;
     int itr;
     prev=0;
     cur=0;
     next=1;
     itr=1;
     for(itr=1;itr<=10;itr++)
     {
          prev=cur;
          cur=next;
          next=cur+prev;
          printf("%d",cur);
      }
}

Well... this one looks nice but if you add comments also to describe each and every variable and steps then you can see the difference.

/* Program Author : Narendrakumar Padmani
    Statement     : Generates first 10 numbers in the Fibonacci series
*/

#include <stdio.h>               //header files Standard input/output

int main(void)                   //Program entry point
{
     int prev;                   //Variable to store previous value
     int cur;                    //Variable to store current value
     int next;                   //Variable to store next value
     int itr;                    //Variable for iterations
     prev=0;                     //variable initializations
     cur=0;
     next=1;
     itr=1;
     for(itr=1;itr<=10;itr++)  //Iterations to generate first 10 numbers in Fibonacci series.
     {
          prev=cur;             // Required operations to generate Fibonacci series
          cur=next;
          next=cur+prev;
          printf("%d",cur);     // Printing numbers generated for the Fibonacci series
      }
}

Finally in the last one you can see all the things looks very professional and readable and

Back

We do not provide any software crack tools or hack tools.