
[![Code comment generator ](https://flow-prompt-covers.s3.us-west-1.amazonaws.com/icon/minimalist/mini_9.png)](https://gptcall.net/chat.html?data=%7B%22contact%22%3A%7B%22id%22%3A%22-g04TdJ4CRgRleXk2Rx79%22%2C%22flow%22%3Atrue%7D%7D)
# Code comment generator  | [Start Chat](https://gptcall.net/chat.html?data=%7B%22contact%22%3A%7B%22id%22%3A%22-g04TdJ4CRgRleXk2Rx79%22%2C%22flow%22%3Atrue%7D%7D)
Generate the comment for code. This prompt works even better on GPT-4. It ignores obvious logic and only comment on complex logics.

# Prompt

```

Act as a software engineer. I will provide a piece of code. You will attach comments onto the code at the right place when necessary. the comment should follow the rules below: 

Rule 1: Comments should not duplicate the code.
Rule 2: Good comments do not excuse unclear code.
Rule 3: If you can’t write a clear comment, point it out to me as [Warning]
Rule 4: Only comment on the function level or on complex logic
Rule 5: Explain unidiomatic code in comments.
Rule 6: Use comments to mark incomplete implementations.
Rule 7: Do not comment on clear code

Now ask me for the code

```

## Conversation

**ASSISTANT**: Please provide me with the code to add comments to.
**USER**: public static void main(String args[])  

{    

 int n1=0,n2=1,n3,i,count=10;    

 System.out.print(n1+" "+n2);//printing 0 and 1    

    

 for(i=2;i<count;++i)//loop starts from 2 because 0 and 1 are already printed    

 {    

  n3=n1+n2;    

  System.out.print(" "+n3);    

  n1=n2;    

  n2=n3;    

 }    


**ASSISTANT**: ```

// This is the main method which will run first when this program executes.

public static void main(String args[])  

{    

    // Initializing variables

    int n1=0,n2=1,n3,i,count=10;    



    // Printing 0 and 1

    System.out.print(n1+" "+n2);



    // Starting the loop from 2 because 0 and 1 are already printed    

    for(i=2;i<count;++i)   

    {    

        // Calculating the Fibonacci number

        n3=n1+n2;  



        // Printing the Fibonacci number    

        System.out.print(" "+n3); 



        // Updating the values of n1 and n2    

        n1=n2;    

        n2=n3;    

    }    

}

```



Note: The code is quite clear, so comments are added only to explain the purpose of the code blocks.


