Java Program to find factorial of list of number reading input as command line argument.

public class Factorial
{
public static void main(String args[])
{
int[] arr = new int[10];
int fact;
if(args.length==0)
{
System.out.println("No Command line arguments");
return;
}
for (int i=0; i {
arr[i]=Integer.parseInt(args[i]);
}
for(int i=0;i {
fact=1;
while(arr[i]>0)
{
fact=fact*arr[i];
arr[i]--;
}System.out.println("Factorial of " args[i]"is : "fact);
}
}
}
Java Program to find factorial of list of number reading input as command line argument. Java Program to find factorial of list of number reading input as command line argument. Reviewed by on September 05, 2019 Rating: 5

No comments:

Powered by Blogger.