0% found this document useful (0 votes)
13 views2 pages

Kotlin

This document contains code snippets demonstrating various Kotlin programming concepts including variables, data types, conditional statements, loops, functions, and more. It defines variables of different types like Int, Float, Boolean and performs operations on them. It shows if-else conditional statements to check conditions. Loops like for and while are used to iterate. Functions are defined to perform operations like addition, subtraction, multiplication and division.

Uploaded by

Kuldeep Khandal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Kotlin

This document contains code snippets demonstrating various Kotlin programming concepts including variables, data types, conditional statements, loops, functions, and more. It defines variables of different types like Int, Float, Boolean and performs operations on them. It shows if-else conditional statements to check conditions. Loops like for and while are used to iterate. Functions are defined to perform operations like addition, subtraction, multiplication and division.

Uploaded by

Kuldeep Khandal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

/*fun main() {*/

// println ("kuldeep"+" ")


//println ("Hello world")o

/*var x=10;
x=x+1
println(x)
variable is a alpha numeric
it should not be a keyword
only underscore is allowed
*/
/* val x=10
x=x+1
*/
//var x : Float = 10.2f
//println (x)
// var x:Boolean = true
// println (x)
/* var age = 15

if (age >=18) {
println("person can vote")

}
else {
println("person can't vote")
}
}*/
/*var day = 5
if (day==1)
println ("Monday")
else if(day == 2)
println ("Tuesday")
else if(day==3)
println("Wednesday")
else if(day==4)
println("Thursday")
else if(day==5)
println("Friday")
else if(day==6)
println("sat")
else if(day==7)
println("sun")
else
println("Default")

}
*/

//loops
//syntax of for loop
/*var sum = 0
for (i in 1..10){
sum = sum + i
//count++
}
println(sum)*/
/*var prod = 1
for ()*/
//while
//syntax of while loop
/* var x=10
while(x>0){
println("kuldeep")
x= x-2;
}*/
//product of even no
/* var n=5
var prod=1
for (i in 1..n){
if(i % 2 ==0) {
prod = prod * i
}
}
println(prod)*/
//for creating function
/*show()
display()
}
fun show() {
println("hello world")
}
fun display() {
println("hello")
}*/
/*fun main(){

println(add(5,2))
println(sub(5,2))
}

fun add (x: Int ,y:Int) :Int{


return x+y
}
fun sub (x:Int , y:Int) :Int{
return x-y
}*/
\

//wap
/*fun main (){
println(prod(5.00,100.00))
println(div(5.00,2.00))
}

fun prod (x:Double ,y:Double) :Double {


return x*y
}
fun div (x:Double,y:Double) :Double {
return x/y
}*/
//fun

You might also like