Coding Standards

You need to ensure that you’re following the below-mentioned coding standards:

1) Function and variable names follow the camel case. For example, getMin(), getMax() and removeDuplicates(), isPresent, etc.

2) Driver code (or main function) does not contain any logic. It contains only input/output and function call.

3) Indentation should be done using 4 spaces.

4) Maximum 60 characters in a line so that the program is readable on mobile devices without much horizontal scrolling.

C




// Below style should be avoided
int fun(int a, int sumSoFar, int currSum, char val, int *result)
   
// The above should be written as
int fun(int a, int sumSoFar, int currSum, char val,
        int *result)


C++




// Below style should be avoided
 cout << "Sample code to understand coding style for more readability of millions of readers" << val;
   
// The above should be written as
cout << "Sample code to understand coding style for"
     << " more readability of millions of readers"
     << val;


5) In case the code is written in multiple languages like Python, Java, and C/C++, the output of all codes should be the same.

6) Avoid the use of scanf (or cin) statements.

7) Spaces in while, if, else, for

C




// There should be one space after while, no other
// spaces
while (i < 0)   
   
if (x < y)
{
   
}


8) There should not be any spaces for a function call or function declaration

C




// No spaces after "reverse" or after "("
void reverse(char* str, int low, int high)
{
    while (low < high)
    {
        swap(&str[low], &str[high]);
        ++low;
        --high;
    }
}   
   
// Driver program to test above function
int main()
{
   char str[] =  "w3wiki";
   reverse(str);
   return 0;
}


9) Avoid the use of typdef.

10) Function names should be of the form “maxOfTwo()”, variable names should be of the form “max_of_two” or same as function name style. Class/Struct names should be of the form “ComplexNumber” or “SuffixTreeNode”. Macro names should be in capital letters like MAX_SIZE.

11) Avoid the use of static and global variables.

12) When we use cout, we must use a space between cout and “<<” and space between two “<<“. For example:

C++




cout << "Sample" << "Example"


13) There should be space after comma in the declaration list and parameter passing.

C




int x, y, z;
  
fun(x, y, z);


14) There should be spaces in assignment operators

C




// Should be avoided
int x, y=0;
   
// Should be followed
int x, y = 0;
   
// Should be avoided
x+=10;
   
// Should be followed
x += 10;


15) At the beginning of every program, please write a line to tell the purpose of the program:

Java




// Java program to illustrate sum of two numbers


Note: It is strongly recommended to add time complexity after your code in data structures/algorithm articles.

How to Write DSA Articles on w3wiki?

w3wiki provides all the coding enthusiasts an opportunity to showcase their programming and Data Structures & Algorithms skills by writing coding or DSA-based articles. However, a lot of individuals (especially college students or beginners) find it difficult to articulate their learnings & skills and contribute at w3wiki. But now the problem has got solved as this article will guide you through the entire process and guidelines of writing Programming/DSA articles at w3wiki.

Let’s get started:

First and foremost, you need to know how to get started with article writing at GFG along with various other fundamental aspects like why should you contribute, where to write, etc. You can check out this link to know all these details in a comprehensive manner.

Similar Reads

How to verify if we can write an article?

Now, you need to check whether you can write an article on a particular topic/problem or not. You can do the same by following the below-mentioned steps:...

Coding Article Format and Guidelines

Moving further, let’s check out the format and guidelines that you need to follow while writing a coding article at GeeksforGeeks. The programming articles should contain the following points:...

Approach Format

If the approach is:...

Sample Approach:

Problem – Print all unique combinations of setting N pieces on an NxN board...

How to Add Code in the Article?

Moving further, now you need to understand the process of adding the code in the article. It is as follows:...

Coding Standards

You need to ensure that you’re following the below-mentioned coding standards:...

Image Creation Guidelines

...