-
-
Save ikhlaqmalik13/a855dd69cab08452079cff9272b3332f to your computer and use it in GitHub Desktop.
Kotlin basics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
var a : Int = 100 // int | |
var name : String = "Muffakir Hamid" // string | |
var percentage : Float = 0.3f // float | |
var charValue : Char = 'y' // char | |
var isLoading : Boolean = true // boolean | |
val schoolName : String = "Salfiya High School" | |
a = 100 | |
println( + 2) | |
} | |
fun printName(name : String) { | |
println("Hello ${name}") | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
var a = 2 | |
var b = 2 | |
var c = a + b | |
println( c) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
// Assignment operators , + - * / % | |
var a = 3 | |
var b = 2 | |
//a = a + 10 // 13 | |
a += 10 | |
var c = a + b | |
println( c) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
var a = 10 | |
var b = 20 | |
println(a>b) | |
println(a<b) | |
print(a==b) | |
println(a>=b) | |
println(a<=b) | |
println(a != b) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
// Logical operators && || | |
var marks = 101 | |
if((marks > 40) && (marks < 50)){ | |
println("Passs") | |
} | |
else if(marks > 50 && marks < 60){ | |
println("Goood...") | |
} | |
else if(marks > 60 && marks < 70){ | |
println("Nice...") | |
} | |
else if(marks > 70 && marks < 90){ | |
println("Outstanding...") | |
} | |
else if(marks > 90 && marks <= 100){ | |
println("Kalkharraaab...") | |
} | |
else{ | |
println("Invalid") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
// Airthmetic operators , + - * / % | |
var a = 3 | |
var b = 2 | |
var c = a % b | |
println( c) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
// Unary operators , + - * / % | |
var bool : Boolean = true | |
//a = a + 1 | |
//a += 1 | |
//a++ | |
//a-- | |
//-a | |
//!bool | |
bool = !bool | |
println(bool) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment