In this article, we are going to present a Kotlin program to add two integer numbers. The program will display the sum result on the screen at the end.
2. Example: Add Two Integer Numbers in Kotlin
The output will be:
In this example, we declared two variables
b with assigned values
9. Note that the explicit determination of the variable's type is not mandatory in Kotlin. The
:Int statement could be skipped, then Kotlin automatically evaluates a type.
Values stored in
b variable are added using the
+ operator. The result of this operation is sored in the
In the next step, we used
println(...) function to print the
sum on the screen.