C++ Articles

Page 144 of 597

Count nodes in Circular linked list in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 1K+ Views

We are given a circular linked list with the nodes and the task is to calculate the count of nodes present in a circular linked list.Circular Linked List is a variation of Linked list in which the first element points to the last element and the last element points to the first element. Both Singly Linked List and Doubly Linked List can be made into a circular linked list.In the below program, we are implementing a singly linked list as a circular linked list to calculate the count of nodes in that.For ExampleInput − nodes-: 20, 1, 2, 3, 4, ...

Read More

Program to find N-th term of series 3, 6, 18, 24, ... in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 462 Views

In this problem, we are given a number N. Our task is to create a Program to find N-th term of series 3, 6, 18, 24, … in C++.Problem Description − To find the Nth term of the series −3, 6, 18, 24, 45, 54, 84 … N TermsWe need to find the general formula for the given series.Let’s take an example to understand the problem, Input − N = 10Output − 150Solution Approach:To find the general term of the series, we will first observe the series and check all the possible generalizations of the series. Like, 3 is common ...

Read More

Count Non-Leaf nodes in a Binary Tree in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 2K+ Views

We are given with a binary tree and the task is to calculate the count of non-leaf nodes available in a binary tree.Binary Tree is a special data structure used for data storage purposes. A binary tree has a special condition that each node can have a maximum of two children. A binary tree has the benefits of both an ordered array and a linked list as search is as quick as in a sorted array and insertion or deletion operation are as fast as in linked list. Non-leaf nodes are also known as parent nodes as they have more ...

Read More

Program to find N-th term of series 3, 12, 29, 54, 86, 128, 177, 234, ..... in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 147 Views

In this tutorial, we will be discussing a program to find N-th term of series 3, 12, 29, 54, 86, 128, 177, 234, …..For this we will be provided with a number. Our task is to find the term for the given series at that particular position.Example#include #include using namespace std; //calculating nth term of given series int nthTerm(int n) {    return 4 * pow(n, 2) - 3 * n + 2; } int main() {    int N = 4;    cout

Read More

Program to find N-th term of series 3, 12, 29, 54, 87, ... in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 224 Views

In this problem, we are given a number N. Our task is to create a program to find N-th term of series 3, 12, 29, 54, 87, … in C++.The series is3, 12, 29, 54, 87, 128, .... N-TermsLet’s take an example to understand the problem, Input − N = 5Output − 87Solution Approach:Let’s deduce the general term of the given series. The series is −3, 12, 29, 54, 87, 128, ....The general term of this series isTn = 4(n2 ) - 3*n + 2Using the general term formula, we can find any value of the series.For example, T8 = ...

Read More

Count and Print the alphabets having ASCII value in the range [l, r] in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 397 Views

We are given with a string of any length and the task is to calculate the count and print the alphabets in a string having ASCII value in the range [l, r]ASCII value for character A-Z are given belowABCDEFGHIJKLMNOPQRS65666768697071727374757677787980818283TUVWXYZ84858687888990ASCII value for characters a-z are given below −abcdefghijklmnopqrs979899100101102103104105106107108109110111112113114115tuvwxyz116117118119120121122For ExampleInput − String str = “point       First = 111, Last = 117 Output − characters in the given range are: p, o , t       Count is: 3Explanation − since p, o and t lies in the range of [111, 117] these characters will be counted.Input − String ...

Read More

Count elements present in first array but not in second in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 194 Views

We are given an array of any size containing integer elements and the task is to calculate the count of elements that are present in the first array but not in the second array..Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.For exampleInput− int arr_1[] = {1, 2, 3, 4}       Int arr_2[] = {1, 5, 6, 7, ...

Read More

Program to find N-th term of series 4, 14, 28, 46, 68, 94, 124, 158, .....in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 682 Views

In this problem, we are given a number N. Our task is to create a program to find N-th term of series 4, 14, 28, 46, 68, 94, 124, 158, …..in C++.Problem Description − To find the Nth term of series4, 14, 28, 46, 68, 94, 124, … (N-terms),  We will find the general term of the series and calculate the value based on the value of n.Let’s take an example to understand the problem, Input − N = 5Output − 68Solution Approach:Let’s deduce the general term of the given series. The series is:4, 14, 28, 46, 68, 94, 124….We ...

Read More

Count number of elements between two given elements in array in C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 11-Mar-2026 2K+ Views

We are given an array containing integer elements and two numbers start and end and the task is to calculate the count of elements present between start and end in an array.Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. If the start element is occurring multiple times then we will consider the first occurrence of the start element and ...

Read More

Program to find N-th term of series 7, 21, 49, 91, 147, 217, ...... in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 173 Views

In this problem, we are given a number n that denotes the nth term of the series. Our task is to create a program to find the N-th term of series 7, 21, 49, 91, 147, 217, …… in C++.Problem Description - We will find the nth term of the series 7, 21, 49, 91, 147, 217, … and for that, we will deduce the general term of the series.Let’s take an example to understand the problem, Input − N = 5Output − 147Solution Approach:Let’s deduce the general term of the given series. The series is −7, 21, 49, 91, ...

Read More
Showing 1431–1440 of 5,962 articles
« Prev 1 142 143 144 145 146 597 Next »
Advertisements