[Solved] Command Line Argument Square with Java, C++

Command Line Argument Square: Write a  program to accept a integer as command line argument and print the square of that integer.

Sample Input (Command Line Argument) 1:

10

Sample Output 1:
Square of the number :
100

Solution

class Main
{
    public static void main(String jr[])
    {
        System.out.println("Square of the number :");
        int a =Integer.parseInt(jr[0]);
        System.out.println(a*a);
        
    }
}

Happy Learning – If you require any further information, feel free to contact me.

Share your love
Saurav Hathi

Saurav Hathi

I'm currently studying Bachelor of Computer Science at Lovely Professional University in Punjab.

📌 Nodejs and Android 😎
📌 Java

Articles: 444

Leave a Reply

Your email address will not be published. Required fields are marked *