count-the-number-of-divisible-numbers-in-a-given-range-1-100-without-loop-in-java.php without loop

count-the-number-of-divisible-numbers-in-a-given-range-1-100-without-loop-in-java.php without loop

Program
public class Main
{
    public static void main(String args[])
    {
        int n=2;
        System.out.print(100/n);
    }
}	

Output:

50

Using CommandLine Arguments
public class Main
{
    public static void main(String args[])
    {
        int n;
        n=Integer.parseInt(args[0]);    
        System.out.print(100/n);
    }
}	

Output:

50

Using Scanner Class
import java.util.*;
public class Main
{
    public static void main(String args[])
    {
        int n;
        Scanner s=new Scanner(System.in);
        System.out.println("Enter n value: ");
        n=s.nextInt();
        System.out.print(100/n);
    }
}	

Output:

Enter n value : 2
50





More Questions


48 . Write a Java-program count the number of divisible numbers in a given range(1-100) ?
49 . Write a Java-program count the number of divisible numbers in a given range(1-100) without loop
50 . Write a Java-program to print Factorial Number using for loop ?
51 . Write a Java-program to print Factorial of upto N Numbers using for loop ?
52 . Write a Java-program to print sum of natural numbers using for loop ?
53 . Write a Java-program to print sum of Even numbers using for loop ?
54 . Write a Java-program to print sum of Odd numbers using for loop ?
55 . Write a Java-program to print sum of even or odd numbers based on the N value using for loop ?
56 . Write a Java-program to print sum of even or odd numbers based on the N value using single for loop ?
57 . Write a Java-program to display the Table using for loop ?
58 . Write a Java-program to display 1 to 10 values using while loop ?