
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Kotlin Program to Print an Integer
In this article, we will understand how to print an integer. Integer is a primitive data type that contains numbers up to 32 bits.
Below is a demonstration of the same ?
Suppose our input is ?
45
The desired output would be ?
The integer is: 45
Algorithm
Step 1 ? START
Step 2 ? Define the integer value in a variable
Step 3 ? Display it on the console
Step 4 ? STOP
Example 1
In this example, we will simply print an integer using the print() method. First, declare an integer variable, which will be our input number
val inputInt = 45
Now, print the above integer using the print() method ?
print("The integer is defined as: " +inputInt)
Let us now see the complete example ?
fun main() { val inputInt = 45 print("The integer is defined as: " +inputInt) }
Output
The integer is defined as: 45
Example 2
Here, we have created a custom function and printed an integer ?
fun printInt(inputInt : Int){ println("The integer is defined as: " +inputInt) } fun main() { val inputInt = 45 printInt(inputInt) }
Output
The integer is defined as: 45
Advertisements