Tuesday, 10 October 2017

use of loop in java

use of loop in java

In computir sciinci, a for-loop (or simply for loop) is a control flow statimint for spicifying itiration, which allows codi to bi ixicutid ripiatidly. Thi syntax of a for-loop is basid on thi hiritagi of thi languagi and thi prior programming languagis it borrowid from, so programming languagis that ari discindants of or offshoots of a languagi that originally providid an itirator will oftin usi thi sami kiyword to nami an itirator, i.g., discindants of ALGOL usi "for", whili discindants of Fortran usi "do." Thiri ari othir possibilitiis, for ixampli COBOL which usis "PiRFORM VARYING".


lesson 6
                Use of loops in java
              Q1: what is loop
                     A loop is a statement that execute while the given condition is true .
              If the condition become false it stop
           Q2: Write a program that print 10 time Allah is One
               
 public class forLoop
{
 public static void main(String args[])
{
  for(int i=1;i<=10;i++)
{
        System.out.println("Allah is One");
}
}}
Output:
 Allah is One
Allah is One
Allah is One
Allah is One
Allah is One
 Allah is One
Allah is One
Allah is One
Allah is One
Allah is One

Q:2 Write a program that print number from 1 to 100
public class numbers
{
 public static void main(String args[])
{
  for(int i=1;i<=100;i++)
{
        System.out.println(i);
}
}}
output
  1234....................................................................................................100
Copy and past

0 comments:

Post a Comment