Programming Articles - Page 554 of 3363

Haskell Program to Calculate simple interest and compound interest

Potti Chandra Sekhar sai
Updated on 24-Nov-2022 06:21:17

546 Views

In this tutorial, we discuss writing a program to calculate simple and compound interest in the Haskell programming language In this tutorial, we see Program to compute Simple interest. Program to compute Compound interest. Simple interest is an Interest method for an investment, where interest is defined as I = p*t*r/100, where p is the invested amount, t is the quantity of time in years, and r is the interest rate. (per 100). Example − For an invested amount of 1000(p), t= 2 and r =3 the interest is 60. Compound interest is an Interest method for an ... Read More

Golang Program to Print Spiral Pattern of Numbers

Akhil Sharma
Updated on 22-Nov-2022 13:06:30

427 Views

In this tutorial, we will learn how to print spiral pattern of Numbers using Go programming language. A Spiral pattern of numbers is used to print numbers in spiral pattern on the screen. In this program we will create an array of size n, store numbers in it and use the array to create a matrix in a spiral format. Syntax for initialization; condition; update { statement(s) } func make([]T, len, cap) []T make() function is used to allocate memory of heap for some variables. For eg we can use make() function to allocate memory for ... Read More

Golang Program to Print Reverse Pyramid Star Pattern

Akhil Sharma
Updated on 22-Nov-2022 13:02:15

691 Views

In this tutorial we will write a Go-lang code to print Reverse pyramid star pattern. We will depict how you can print the reverse pyramid star pattern. ********* ******* ***** *** * How to print a Reverse Pyramid star pattern? A pattern is shown above, and in the pattern, you can clearly see that 2 stars is decreasing with increase in each row. If the total rows are 5, the pattern goes like ... Read More

Golang Program to Print Pyramid Star Pattern

Akhil Sharma
Updated on 22-Nov-2022 12:58:40

920 Views

In this tutorial we will write a Go language code to print pyramid star pattern. We will depict how you can print the pyramid star pattern. * * * * * * * * * * * * * * * * * * * * * * * * * How to print a Pyramid star pattern? A pattern is shown above, and in the pattern, you can clearly see that 2 stars is increasing with increase in ... Read More

Golang Program to convert int type variables to String

Akhil Sharma
Updated on 22-Nov-2022 12:49:27

17K+ Views

In this tutorial we will learn how to convert int type variables to string variables using Golang programming language. A string is defined as the sequence of one or more characters (letters, numbers, or symbols). Computer applications frequently use strings as a data type thus, there is a need to convert strings to numbers or numbers to strings at manny places specially when we are using data entered by the user. Syntax func Itoa(x int) string Itoa() function in go programming language is used to get the string representation of any integer value here it is depicted by ... Read More

Golang Program to convert double type variables to string

Akhil Sharma
Updated on 22-Nov-2022 12:21:36

920 Views

In this tutorial we will learn how to convert double(float64) type variables to string variables using Golang programming language. Double stands for double precision. In programming languages, a double data-type is used to handle decimal numbers more precisely i.e. using double data type we can store more number of digits after a decimal point with accuracy. String data type is used to store a sequence of characters. It can be in the form of literals or alphabets. The size of string variable is 1 byte or 8 bits. EXAMPLE 1: GO LANGUAGE CODE TO CONVERT DOUBLE TYPE ... Read More

Golang Program to convert double type variables to int

Akhil Sharma
Updated on 22-Nov-2022 12:16:02

3K+ Views

In this tutorial we will learn how to convert double type variables to integer variables using Golang programming language. Double stands for double precision. In programming languages, a double data-type is used to handle decimal numbers more precisely i.e. using double data type we can store more number of digits after a decimal point with accuracy EXAMPLE 1: GO LANGUAGE CODE TO CONVERT DOUBLE TYPE VARIABLES TO INT: Syntax fmt.Println(int(b)) Int(x) To convert a float type input ... Read More

What is the meaning of the question mark "?" in Swift?

Nitin Aggarwal
Updated on 22-Nov-2022 11:15:11

2K+ Views

In this tutorial, you will learn what is a question mark in the Swift language, how to use it, and what it is used for. What does the question mark indicate? This question mark indicates that a variable might contain a nil value or some value of type declared with the variable. Before learning what a question mark is, let's understand what are optionals in Swift. Optionals When you create a variable in the Swift language, either it can contain an initial value or it might be holding nothing at the initial point. In that ... Read More

What Is Defer in Swift?

Nitin Aggarwal
Updated on 22-Nov-2022 11:11:52

6K+ Views

In this tutorial, you will learn what the defer keyword is and how it can be used in Swift. You will see in what situations you can use the defer keyword. What is defer? A defer is a statement that is used for executing code just before transferring program control outside of the scope that the statement appears. The defer statement is not something you will need to use often in Swift. It will be useful in situations when you want to clean resources before they go out of scope. The defer keyword was introduced in the ... Read More

What is a guard statement in Swift?

Nitin Aggarwal
Updated on 22-Nov-2022 11:08:23

3K+ Views

In this tutorial, you will learn about what is a guard statement and how it is implemented in the Swift language. Let's learn. What is a guard statement? In Swift, the guard is a statement that transfers control between codes like an if-else statement. The guard statement is the most commonly used statement in Swift. When certain conditions are not met to allow the flow to continue, the guard statement is used to transfer flow control. A guard statement is similar to an if statement with one major difference. The if statement runs when a certain condition ... Read More

Advertisements