Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

print all numbers from 1 to n java

// Java Program to Print Natural Numbers from 1 to N 
import java.util.Scanner;

public class NaturalNumbers1 {
	private static Scanner sc;
	public static void main(String[] args) 
	{
		int number, i;
		sc = new Scanner(System.in);
		
		System.out.print(" Please Enter any Number : ");
		number = sc.nextInt();	
		
		for(i = 1; i <= number; i++)
		{
			System.out.print(i +"	"); 
		}	
	}
}
Source by www.tutorialgateway.org #
 
PREVIOUS NEXT
Tagged: #print #numbers #java
ADD COMMENT
Topic
Name
1+9 =