Sunday 24 March 2013

A Java Program for Find the Factorial of given number Using Command line Arguments.


import java.io.*;
class pr2
{
public static void main(String args[])throws IOException
{
DataInputStream br=new DataInputStream(System.in);
System.out.println("Enter the Number:->");
int No=Integer.parseInt(br.readLine());
int fact=1,i=1;
for(i=1;i<=No;i++)
{
fact=fact*i;
}
System.out.println("The Factorial of ["+No+"] is :=>"+fact);
}
}

No comments:

Post a Comment

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...