Find the Perimeter of a Circle in Haskell

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 12:00:56

367 Views

This tutorial discusses writing a program to find the perimeter of a circle in the Haskell programming language. The perimeter of the circle is the length of the boundary of the circle. The perimeter of a circle is also called the circumference. The perimeter of a circle is defined as 2*pi*r where r is the radius of the circle. For example area of the circle with a radius of 4 units is 25.13274 (2*pi*4). In this tutorial, we see two ways to implement a program to find the perimeter of a circle. Program to find the perimeter of ... Read More

Haskell Program to Find the Area of a Trapezium

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:55:05

161 Views

This tutorial discusses writing a program to print the area of a trapezium in the Haskell programming language. A trapezium is a quadrilateral with one opposite side parallel. The above figure is a trapezium. The length of one of the parallel sides is denoted by a and the other side is denoted by b. The height of the trapezium is denoted by h. The area of a trapezium is defined as (a+b)/(2*h), where a and b are the lengths of the parallel sides and h is the height or distance between the parallel sides. In this tutorial, we see ... Read More

Find the Area of a Square in Haskell

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:53:01

510 Views

This tutorial discusses writing a program to print the area of a square in the Haskell programming language. The square is a quadrilateral with all sides of the same length. The area of a square is equal to the square of the size of the side. If the side of the square has a size of 5 units, then the area of that is 25 units(5*5). In this tutorial, We see four ways to implement. Program to compute the area of a square using the infix operator “*”. Program to compute the area of a square using the ... Read More

Create Hashtable Collection in C#

Shilpa Nadkarni
Updated on 14-Dec-2022 11:49:16

233 Views

The HashTable is a non−generic collection in C#. It stores key-value pairs and is similar to a generic “Dictionary” collection. HashTable is defined in System. Collections. namespace. HashTable computes the hash code of each key and stores it in a different bucket internally. The hash code is then matched to the hash code of the specified key when the values are accessed. Thus the lookups are optimized by HashTable. In this tutorial, we will see how we can create a HashTable collection in C#. Hashtable Features Before we jump to creating a HashTable, let us see some of ... Read More

Check If Key Exists in Hashtable in C#

Shilpa Nadkarni
Updated on 14-Dec-2022 11:47:21

2K+ Views

The Hashtable class in C# represents a collection of key-value pairs. These key-value pairs are organized based on the hash code of the key that is calculated using the hash code function. The key in the hashtable accesses the items. So given a key, we can access the corresponding value for that key in the hashtable. The keys in the hashtable are unique and non-null. The values however can be null or duplicated. We have been discussing hashtable topics in our earlier tutorials. We continue the trend in this article as well. In this article, we will discuss how to ... Read More

Calculate the Power of a Number in Haskell

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:41:06

1K+ Views

This tutorial discusses writing a program to calculate the power of a number in the Haskell programming language. The nth power of a number is the value when the number is multiplied by itself n times. The power of numbers can be expressed in exponential forms “a^n”, a is raised to the power of n. Here a is called the base and n is called an exponent. For example, 2 raised to the power of 5 is 2^5 i.e 32. In this tutorial, we see different ways to implement a program to calculate the power of a number. Program ... Read More

Add Items to Hashtable Collection in C#

Shilpa Nadkarni
Updated on 14-Dec-2022 11:40:06

794 Views

We have already discussed the basics of hashtables. A hashtable collection in C# is used to store key−value pairs wherein each of these key-value pairs is organized based on the hash code of the key. This hash code is calculated using a hash code function. Internally, the hashtable uses buckets to store data. A bucket is nothing but a virtual group of elements within the hashtable. A hash code is associated with each bucket. Programmatically, a hashtable is similar to a dictionary object but unlike in dictionary object, a hashtable can store objects of different data types. Performance−wise, hashtables exhibit ... Read More

Find Surface Area and Volume of Cuboid in Haskell

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:36:41

284 Views

This tutorial discusses writing a program to find the Surface area and volume of a cuboid in the Haskell programming language. A cuboid is a solid shape that has six rectangular faces. A cuboid has three dimensions length, breadth, and height. The surface area of a cuboid is the total area of the six rectangular faces i.e 2*length*breadth + 2*length*height + 2*breadth*height. The volume of the cuboid is length*breadth*height. As volume is area*height. In this tutorial we see, Program to find the surface area of a cuboid. Program to find the volume of a cuboid. Algorithm Steps ... Read More

Count Number of Digits in an Integer using Haskell

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:33:52

1K+ Views

In this tutorial, we discuss writing a program to count the number of digits in an integer in the Haskell programming language. In this tutorial, we see three ways to implement a program to count digits in Haskell. Program to count the number of digits in an integer. Program to count the number of digits in an integer using if-else.Program to count the number of digits in an integer using the length function. Algorithmic Steps Take input or initialize a variable for an integer. Implement the program logic to count the digits in an integer. Print or display ... Read More

Haskell Program to Reverse a Number

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 11:30:06

822 Views

This tutorial discusses writing a program to reverse a number in the Haskell programming language. In this tutorial, we see two ways to implement a program in Haskell to reverse a number. Program to reverse a number using the list function reverse. Program to reverse a number using a recursive function. Example 1 Program to reverse a number using the list function reverse. -- function declaration reverseNumber :: Int->Int -- function definition reverseNumber n = k where temp = reverse (show n) ... Read More

Advertisements