Horje
Guidelines for adding C++/Java/Python/C#/JavaScript code to existing articles of GeeksforGeeks
You may please first go through code writing instructions: Guide to write an articleGuidelines for writing code for an existing code on GeeksforGeeks:
  1. This guideline is for those who directly write in https://write.horje.org/. To write code in multiple languages use the format shown below: Click on the Add Code button present in the Toolbar provided. Improve-Article-02 Click on the Add Another Language button and further select the language to be added from the drop-down list provided. Improve-Article-03 Use the Arrow Keys to change the sequence of the codes. Improve-Article-04 To Format your code, use the Format button provided. Further, use the Run button to check if your code generates the correct output and click on the Proceed button to add your code with the other existing codes. Improve-Article-05
  2. Please note that all of these attributes must match in all the programs:
    1. Variable names
    2. Function names
    3. Comments
    4. Output
    5. Approach used (Say, if stack is used to solve a problem, then all problems MUST be solved using stack)
    See the following examples: C++
    // C++ program to find factorial of given number
    #include 
    using namespace std;
    
    // function to find factorial of given number
    unsigned int factorial(unsigned int n)
    {
        if (n == 0)
            return 1;
        return n * factorial(n - 1);
    }
    
    // Driver code
    int main()
    {
        int num = 5;
        cout 
    
    Python3
    # Python 3 program to find
    # factorial of given number
    
    # Function to find factorial of given number
    def factorial(n):
        
        if n == 0:
            return 1
        
        return n * factorial(n-1)
    
    # Driver Code
    num = 5;
    print("Factorial of", num, "is",
    factorial(num))
    
    # This code is contributed by Smitha Dinesh Semwal
    
    Java
    // Java program to find factorial of given number
    class Test {
        // method to find factorial of given number
        static int factorial(int n)
        {
            if (n == 0)
                return 1;
    
            return n * factorial(n - 1);
        }
    
        // Driver method
        public static void main(String[] args)
        {
            int num = 5;
            System.out.println("Factorial of " + num
                            + " is " + factorial(5));
        }
    }
    
    C#
    // C# program to find factorial
    // of given number
    using System;
    
    class Test {
        // method to find factorial
        // of given number
        static int factorial(int n)
        {
            if (n == 0)
                return 1;
    
            return n * factorial(n - 1);
        }
    
        // Driver method
        public static void Main()
        {
            int num = 5;
            Console.WriteLine("Factorial of "
                            + num + " is " + factorial(5));
        }
    }
    
    // This code is contributed by vt_m
    
    JavaScript
    // Javascript to find factorial
    // of given number
    
    // function to find factorial
    // of given number
    function factorial(n) {
    if (n == 0) return 1;
    return n * factorial(n - 1);
    }
    
    // Driver Code
    let num = 5;
    document.write("Factorial of " + num + " is " + factorial(num));
    
    // This code is contributed by Saurabh Jaiswal
    
  3. Please put your name at the end in comments if you wish to. For example:
     // This code is contributed by Amit Khandelwal
  4. During submission of Code Addition Mention ‘LanguageName – Code Addition‘ in Reason to Improve box and Select Type – Code Addition and then click on Submit for Review.
  5. If you wish to improve an existing code in one language before adding your code, you can first email us modified existing code first to [email protected].



Reffered: https://www.geeksforgeeks.org


Programming Language

Related
C program to print name pattern C program to print name pattern
10+ Free Online Coding for Kids Resources: Websites & Apps 10+ Free Online Coding for Kids Resources: Websites & Apps
Language Evaluation Criteria Language Evaluation Criteria
Design Goals and Principles of Object Oriented Programming Design Goals and Principles of Object Oriented Programming
Assembly in VB.NET Assembly in VB.NET

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
16