Found 33676 Articles for Programming

Haskell Program To Check Whether The Input Number Is A Palindrome

Potti Chandra Sekhar sai
Updated on 15-Dec-2022 11:42:10

562 Views

This tutorial discusses writing a program to check whether the input number is a Palindrome number in the Haskell programming language. A number can be called as a palindrome when it results in the same number when the digits are reversed. For Example, the number 12321 is a palindrome, because after reversing the digits it results in the same number. In this tutorial we see, Program to check whether the input number is a palindrome using the string reverse function. Program to check whether the input number is a palindrome using the recursive function. Method 1: Checking Palindrome ... Read More

Haskell Program to print Hello World!

Potti Chandra Sekhar sai
Updated on 15-Dec-2022 11:40:23

2K+ Views

This tutorial will discuss writing a program to print Hello World! in Haskell Programming Language. The Computations in Haskell are done using mathematical functions. In this tutorial, We will discuss different ways to print Hello World! in Haskell. Program to print Hello World! Using the “print” function. Program to print Hello World! Using the “putStr” function. Program to print Hello World! Using the “putStrLn” function. Example Program to print Hello World! Using the “print” function main :: IO() main = do -- printing using the function print print ("Hello World!") Output Hello World! ... Read More

Haskell Program To Check Whether The Input String Is A Palindrome

Potti Chandra Sekhar sai
Updated on 15-Dec-2022 11:39:09

1K+ Views

This tutorial discusses writing a program to check whether the input string is a palindrome in the Haskell programming language. A string is said to be a palindrome when it results in an exact string after reversing it. For example, the string “level” is a palindrome because it results in an exact string even after reversing it. In this tutorial we see, Program to check whether the string is a palindrome using a built-in function reverse. Program to check whether the string is a palindrome using a recursive function. Method 1: Checking The String Is A Palindrome Using ... Read More

Haskell Program To Find The Factorial Of A Positive Number

Potti Chandra Sekhar sai
Updated on 15-Dec-2022 11:36:27

936 Views

This tutorial discusses writing a program to find the factorial of a positive number in the Haskell programming language. In this tutorial, we see Program to find the factorial of a positive number using a recursive function. Program to find the factorial of a positive number using an inbuilt function product. Algorithm Steps Take input or initialize a variable to store a positive integer. Implement program logic to find the factorial of a number. Print the resulting factorial. Method: Find The Factorial Of A Positive Number Using A Recursive Function Example Program to find the factorial ... Read More

Haskell program to convert a decimal number into a binary number

Potti Chandra Sekhar sai
Updated on 15-Dec-2022 11:33:48

758 Views

This tutorial discusses writing a program to convert a decimal number into a binary number in the Haskell programming language. Haskell is a Declarative, Strongly Typed, and Functional programming Language. The computations in Haskell are mathematical functions. In a Decimal number system, each number is denoted with numbers ranging from 0-9. This number system is also called as base 10 number system. For example, The number four hundred and ninety-one is represented as 491(4*10^2 + 9*10^1 + 1*10^0). In a Binary number system, each number is represented as numbers ranging from 0-1. This number system is also called as base ... Read More

C++ Program To Find the Trace and Normal of a given Matrix

Arnab Chakraborty
Updated on 14-Dec-2022 15:09:38

1K+ Views

Several applications greatly benefit from the use of 2-dimensional arrays or matrices. Numbers are stored in rows and columns of matrices. Using multi-dimensional arrays, we may define 2D matrices in C++ as well. In this post, we'll look at how to use C++ to determine the Normal and Trace of a given matrix. The square root of the total number of elements in the matrix is what is known as the Normal. The trace is made up of all the components that make up the main diagonal. Let's look at the representation of the algorithm in C++ code. Matrix Trace ... Read More

C++ Program to Compute the Sum of Diagonals of a Matrix

Arnab Chakraborty
Updated on 14-Dec-2022 16:04:28

7K+ Views

The utilization of 2-dimensional arrays or matrices is extremely advantageous for several applications. Matrix rows and columns are used to hold numbers. We can define 2D matrices in C++ using multi-dimensional arrays as well. In this article, we'll look at how to use C++ to calculate the diagonal sum of a given square matrix. The matrices have two diagonals, the main diagonal and the secondary diagonal (sometimes referred to as major and minor diagonals). The major diagonal starts from the top-left corner (index [0, 0]) to the bottom-right corner (index [n-1, n-1]) where n is the order of the square ... Read More

C++ Program to Compare two strings lexicographically

Arnab Chakraborty
Updated on 02-Dec-2024 00:22:48

10K+ Views

Lexicographic string comparison states the strings are compared in dictionary order. For example, if two strings ‘apple’ and ‘appeal’ are there, the first string will come next because the first three characters ‘app’ are the same. Then for the first string, the character is ‘l’ and in the second string, the 4th character is ‘e’. Since ‘e’ is shorter than ‘l’, it will come first if we arrange them in lexicographic order. Before arranging, the strings are compared lexicographically. In this article, we will see different techniques to compare two strings in a lexicographic manner using C++. Using compare() functions ... Read More

C++ Program to Print first letter of each word using regex

Arnab Chakraborty
Updated on 14-Dec-2022 14:45:07

495 Views

A useful tool for string operations is regex. This may be found in virtually all high-level current programming languages, including C++. Regular expressions (Regex) are utilized as general-purpose search patterns. For instance, by constructing a straightforward string known as a regular expression, we may implement password validation logic with at least one capital, one lowercase, one number, one special character, and a total length of at least 8 characters. In this tutorial, we'll look at how to use C++ to display only the first letters of words included within a specified string. Here, we'll look at a sentence that uses ... Read More

C++ Program to Swapping Pair of Characters

Arnab Chakraborty
Updated on 14-Dec-2022 14:39:09

3K+ Views

A string is a group of characters. They can be described as character arrays as well. An array of characters can be thought of as strings, and each string has a set of indices and values. The switching of characters at two specified indices in a string is one of the modifications we can sometimes make to strings. In this article, we will see how to swap two characters in a string from two given indices using C++. Syntax char temp = String_variable[ ] String_variable[ ] = String_variable[ ] String_variable[ ] = temp Using indices, ... Read More

Advertisements