Found 33676 Articles for Programming

C++ Program to Replace a Character at a Specific Index

Arnab Chakraborty
Updated on 14-Dec-2022 14:37:16

2K+ Views

Strings are a collection of characters. We can also say them as character arrays. Considering an array of characters as strings, the strings have specified indices and values. Sometimes we can perform some modification on strings, one such modification is replacing characters by providing a specific index. In this article, we will see how to replace a character from a specific index inside a string using C++. Syntax String_variable[ ] = In C++ we can access the string characters using indices. Here to replace a character with some other character at a specified index, we simply ... Read More

C++ Program to Iterate Over an Array

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

4K+ Views

Arrays are data of the same type stored in contiguous locations in memory. To access or address an array, we use the starting address of the array. Arrays have indexing, using which we can access the elements of the array. In this article, we take a look at methods to iterate over an array. This means accessing the elements that are present in an array. Using for loop The most common method of iterating over an array is using for loops. We use a for loop to iterate through an array in the next example. One thing is to be ... Read More

Haskell Program to Display Fibonacci Series

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 13:56:06

2K+ Views

This tutorial discusses writing a program to display Fibonacci Series in the Haskell programming language. The Fibonacci series is a sequence in which each number is the sum of the preceding two terms. The Fibonacci series up to five terms is 0 1 1 2 3. In this tutorial we see, Program to print nth fibonacci number. Program to print the first ‘n’ terms in the Fibonacci series. Program to print the first ‘n’ terms in the Fibonacci series using the list comprehension. Program to print the first ‘n’ terms in the Fibonacci series using the map function. ... Read More

C++ Program to Find the Normal and Trace

Arnab Chakraborty
Updated on 14-Dec-2022 14:50:37

427 Views

2-Dimensional arrays or matrices are very much useful in several applications. Matrices have rows and columns and store numbers inside them. In C++ also we can define 2D matrices using multi-dimensional arrays. In this article, we will see how to calculate the Normal and the Trace of a given matrix using C++. The Normal is the square root of the sum of all elements present in the matrix. And the trace is the sum of elements present in the main diagonal. Let us see the algorithm and C++ code representation. Matrix Normal $\begin{bmatrix} 5 & 1& 8ewline 4 ... Read More

C++ Program to Copy All the Elements of One Array to Another Array

Arnab Chakraborty
Updated on 14-Dec-2022 12:22:48

4K+ Views

The array data structures are used to store homogeneous data in a consecutive memory location to access them in a sequential manner. Arrays are linear data structure so that the basic operations on array can be performed in linear time. In this article we will see how to copy elements from one array to another new array in C++. The new array will be of same type since array elements are homogeneous. After creating another array of same size, we simply copy the elements from first array to the second one by one. Let us see the algorithm and the ... Read More

Haskell program to check whether the input number is a Prime number

Potti Chandra Sekhar sai
Updated on 14-Dec-2022 12:21:57

398 Views

This tutorial discusses writing a program to check whether the input number is a Prime number in the Haskell programming language. Haskell is a Declarative, Strongly Typed, and Functional programming Language. The computations in Haskell are mathematical functions. A prime number is a number having only 1 and the number itself as a factor. Note 1 is neither a prime nor a composite number because it has only one factor. For example, 3 is a prime number because it has only two factors 1 and the number 3 itself. In this tutorial we see, Program to check whether a ... Read More

C++ Program to Sort the Elements of an Array in Ascending Order

Arnab Chakraborty
Updated on 14-Dec-2022 12:21:17

13K+ Views

To solve some problems effectively, it's important to arrange the data items in the correct sequence. One of the most popular arranging problems is the element sorting problem. This article will demonstrate how to arrange array members in C++ in ascending order (according to rising values). To arrange either numerical or non-numerical elements in a specific order, a wide variety of sorting algorithms are available in this field. Only two straightforward sorting techniques will be covered in this article. the selection sort and the bubble sort. Let's examine each one individually using appropriate techniques and C++ implementation code. Sort array ... Read More

C++ Program to Sort the Elements of an Array in Descending Order

Arnab Chakraborty
Updated on 14-Dec-2022 12:18:13

2K+ Views

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

Haskell Program to Print the Multiplication Table in Triangular Form

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

294 Views

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

C++ Program to Convert Set of String to Array of String

Arnab Chakraborty
Updated on 14-Dec-2022 12:15:06

2K+ Views

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

Advertisements