Looping is a programming language statement which allows code to be repeatedly executed. A for loop is classified as an iteration statement. Unlike many other kinds of loops, such as the while loop, the for loop is often distinguished by an explicit loop counter or loop variable.
there are three different type of looping, used in programming.
1. while Loop
2. do while Loop
3. for Loop
Showing posts with label for loop. Show all posts
Showing posts with label for loop. Show all posts
Monday, August 2, 2010
Friday, April 30, 2010
for loop sample program
sample program using for loop in java.
this program will ask the user to input how many numbers they want to print:
import java.util.Scanner;
public class samplefor
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
int num;
int x;
System.out.print("How many numbers you want to print:");
num=input.nextInt();
for(x=0; x<=num; x++)
{
System.out.println(x");
}
}
}
this program will ask the user to input how many numbers they want to print:
import java.util.Scanner;
public class samplefor
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
int num;
int x;
System.out.print("How many numbers you want to print:");
num=input.nextInt();
for(x=0; x<=num; x++)
{
System.out.println(x");
}
}
}
Labels:
for loop,
input numbers,
looping,
util.scanner
Thursday, April 29, 2010
for Loop
for loop is a part of programming to execute program continuesly until it reaches the final looping of final number of loop.
example program.
int x;
for(x=0; x<=10; x++)
{
System.out.println(x);
}
sample output:
0
1
2
3
4
5
6
7
8
9
10
example program.
int x;
for(x=0; x<=10; x++)
{
System.out.println(x);
}
sample output:
0
1
2
3
4
5
6
7
8
9
10
Labels:
for loop,
looping,
program from 0 to 10
Tuesday, April 27, 2010
syntax in programming
syntax is a rules in programing.
for loop sysntax:
for(init; condition; inc/dec)
{
statements;
}
for loop sysntax:
for(init; condition; inc/dec)
{
statements;
}
Subscribe to:
Posts (Atom)