Tuesday, June 14, 2011

for loop with iteration example

public class appleprice {
    public static void main(String[] args) {
        int apple,cost,price;
        cost=10;
       
        /* using { after for statement will use block and execute iterations if you remove block it wont show iterations */

        for (apple=1; apple <10; apple++) {
            price = cost * apple;
            System.out.println("price of  " + apple + "   apple is  " +price);
        }
           
           
    }

}

No comments:

Post a Comment