12:20 am - Thursday March 23, 2017

Java Example Program to display Numbers from 1 to N using While Loop

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
@author:candidjava.com
@description:Program to display Numbers from 1 to N using While Loop
*/
public class displaynumbers {
	public static void main(String org[]) {
		int i = 1;
		int N = 10;// take variable N value is 10
		while (i <= N)// condition for print 1 to N values
		{
			System.out.println(i);
			i++;
		}
	}
}

Output:
1
2
3
4
5
6
7
8
9
10

Filed in: Sample Programs in java

Comments are closed.