Twitter Facebook Delicious Digg Stumbleupon Favorites More

Sunday 22 July 2018

kotlin for loop

fun main(args:Array<String>)
{
    for (item in 1..5)
    {
        println("hey theree $item")
    }
}
  • OUTPUT  
  • hey theree 1
  • hey theree 2
  • hey theree 3
  • hey theree 4
  • hey theree 5
  • fun main(args:Array<String>)
    {
        for (item in 0..6)
        {
            if (item % 2 ==0)
            {//if the no is divisible by 2 or multiple of 2            println(" $item  is multiple  of $item   fizz")
            }
            else if(item%3==0)
            {
                println("buzz")
            }
    
    
    
        }
    }
  • OUTPUT 
  •  0  is multiple  of 0   fizz
  •  2  is multiple  of 2   fizz
  • buzz
  •  4  is multiple  of 4   fizz
  •  6  is multiple  of 6   fizz

          Share:

          0 comments:

          Post a Comment

          Search This Blog

          Popular Posts

          Pages

          how to make crores from 1 lakh in stock markets in 1 year

          how to make crores from 1 lakh in stock markets in 1 year

          Blogger Tutorials

          Blogger Templates

          Sample Text

          Copyright © ANDROID TUTORIAL CODE | Powered by Blogger
          Design by SimpleWpThemes | Blogger Theme by NewBloggerThemes.com & Distributed By Protemplateslab