This tutorial discusses writing a program to print the multiplication table in the triangular form in the Haskell programming language. For example, the multiplication table for the number 10 in the triangular format is 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25 6 12 18 24 30 36 7 14 21 28 35 42 49 8 16 24 32 40 48 56 64 9 18 27 36 45 54 63 72 81 10 20 30 40 50 60 70 80 90 100 Algorithm Steps Take input or initialize an integer variable ... Read More
Arranging data items in a proper form is an essential task while solving some problems in an efficient way. The element sorting problem is one of the most commonly discussed arranging problem. In this article we will see how to arrange the array elements in descending order (decreasing order of their values) in C++. There are many different sorting algorithms present in this domain to sort numeric or nonnumeric elements in a given order. In this article we will see only two simple methods of sorting. The bubble sort and the selection sort. Let us see them one by one ... Read More
Sets in C++ re containers that contain unique values of a specific type. Arrays or the array container in std C++ is a fixed-size container that contains elements of a specific size. Arrays are like vectors, but the main difference is that arrays are of a fixed size whereas vectors can be dynamic. The array container in C++ is a wrapper for the standard arrays that are available in both C and C++. There is a problem in this conversion though, std arrays do not have support for the common insertion methods that are available with the other containers. So, ... Read More
This tutorial discusses writing a program to swap two numbers in the Haskell programming language. Variables are immutable in Haskell i.e once declared their values cannot be changed. So we cannot swap the values of two variables, but we can mimic this by swapping values in a list and tuple. In this tutorial we see, Program to swap two numbers in a binary tuple. Program to swap two numbers in a list. In Haskell, tuples are used to store elements of different data types as a collection. Tuples are identified by parenthesis at the ends. Tuples support only ... Read More
Lists in C++ are containers the same as vectors, but list implementation is based on doubly linked lists compared to the array implementation of vectors. Lists generally do not contain elements in contiguous locations, the elements of a list are distributed throughout the memory. Lists offer the same constant time operations anywhere in it, that is the main feature of using lists. Sets on the other hand are containers that contain unique values of a certain type and all the elements are sorted in ascending order. The two containers are different, but there are various ways to convert a list ... Read More
This tutorial discusses writing a program to find the operating system info in the Haskell programming language. Haskell provides functions to find the system info. These functions can be accessed by importing the Info module from the System package in Haskell. In this tutorial, we see Program to display the name of the Operating System. Program to display the architecture of the processor. Program to display the compiler name. Program to display the compiler version. Syntax To import a module in Haskell the syntax is to follow. import packageName.moduleName To import the Info module from the system ... Read More
Displaying star patterns in different shapes, like pyramids, squares, and diamonds, is a common part of basic programming and logic development. We faced various problems involving stars and numerical patterns as we studied looping statements in programming. This article will demonstrate how to print an X or a cross using stars. We will see two methods for the same. First one is little bit complicated but the next method is much efficient. X Star Pattern (Using two sets of blank spaces) * * * * * ... Read More
This tutorial discusses writing a program to perform nCr combinations in the Haskell programming language. The nCr is used to find the number of ways r items can be selected from n items given that order doesn’t matter. The nCr is defined as n! / ( r! (n-r)! ). For example number of ways in which 3 items can be selected from 5 items is 5! / ( 3! (5-3)! ), i.e 10 ways. In this tutorial we see, Program to find the factorial of a number (helper function to find the nCr combinations). Program to find the ... Read More
Displaying star patterns in different formats like pyramids, squares, and diamonds is very common in fundamental programming and logic building. We have seen several stars and number pattern problems while learning looping statements in programming. In this article, we will see how to print a hollow right triangle star pattern in C++. In this program, we take the line number n this will create a star pattern for n number of lines. Let us see the example for the same. Hollow Right Star Pattern * ... Read More
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 consists of key/value pairs in which each key is computed as a hash code and stored in a different bucket internally. Whenever the HashTable is accessed, this hash code is matched to the hash code of the specified key and thus the corresponding values are accessed. This mechanism optimizes the lookup in the HashTable. Let’s now discuss how to get keys from a HashTable in C#. How to Get Keys from a HashTable? ... Read More