Blog

python tutorials and learn python

Created with Sketch.

Kotlin Program to Multiply two Floating Point Numbers

Kotlin Program to Multiply two Floating Point Numbers In this program, you’ll learn to multiply two floating point numbers in Kotlin, store the result and display it on the screen. Example: Multiply Two Floating Point Numbers fun main(args: Array<String>) { val first = 1.5f val second = 2.0f val product = first * second println(“The…
Read more

Kotlin Program to Add Two Integers

Kotlin Program to Add Two Integers In this program, you’ll learn to store and add two integer numbers in Kotlin. After addition, the final sum is displayed on the screen. Example: Kotlin Program to Add Two Integers fun main(args: Array<String>) { val first: Int = 10 val second: Int = 20 val sum = first…
Read more

Kotlin Program to Print an Integer (Entered by the User)

Kotlin Program to Print an Integer (Entered by the User) In this program, you’ll learn to print an integer entered by the user. The integer is stored in a variable and printed to the screen using nextInt() and println() functions respectively. Example 1: How to Print an Integer entered by an user in Kotlin using…
Read more

Kotlin Examples

Kotlin Examples The best way to learn any programming language is by practicing examples on your own. You are advised to take references of these examples and try them on your own. All Kotlin programs in this page are tested and should work on almost all Kotlin compilers. Feel free to use the source code…
Read more

C Programming Code To Create Pyramid and Pattern

C Programming Code To Create Pyramid and Pattern Examples to print half pyramid, pyramid, inverted pyramid, Pascal’s Triangle, and Floyd’s triangle in C Programming using control statements.     Example code to create pyramids and patterns in C programming language:   Pattern These are just examples and can be modified to create different patterns and…
Read more

C Program to Display its own Source Code as Output

C Program to Display its own Source Code as Output In this example, you’ll learn to display the program’s source using the __FILE__ macro. Though this problem seems complex but, the concept behind this program is straightforward; display the content from the exact file you are writing the source code.   A predefined macro __FILE__…
Read more

C Program to Read a Line From a File and Display it

C Program to Read a Line From a File and Display it This program reads text from a file and stores it in a string until entering the ‘newline’ character is encountered. Example: Program to read text from a file If the file program.txt is not found, this program prints an error message. If the…
Read more

C Program to Write a Sentence to a File

C Program to Write a Sentence to a File In this example, you’ll learn to write a sentence to a file using fprintf() statement. This program stores a sentence entered by the user in a file.   Output Enter sentence: I am awesome and so are files. After the termination of this program, you can…
Read more

C Program to Store Information Using Structures with Dynamically Memory Allocation

C Program to Store Information Using Structures with Dynamically Memory Allocation In this example, you’ll learn to store information using structures by allocation of dynamic memory using malloc(). This program asks the user to store the value of noOfRecords and allocates the memory for the noOfRecords structure variable dynamically using malloc() function.   Example: Demonstrate the Dynamic…
Read more

C Program to Store Information of Students Using Structure

C Program to Store Information of Students Using Structure This program stores the information (name, roll and marks) of 10 students using structures. In this program, a structure, student is created. This structure has three members: name (string), roll (integer) and marks (float). Then, we created a structure array of size 10 to store information…
Read more