C++ Articles

Page 146 of 597

Program to find remainder when large number is divided by 11 in C++

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

In this problem, we are given a string num which is a large number. Our task is to create a program to find remainder when large number is divided by 11 in C++.Problem Description − We need to find the remainder when the number defined by the string is divided by 11.Let’s take an example to understand the problemInputnum = “43212981843718452”Output7Solution ApproachTo find the remainder, we obviously need to divide the number. But dividing huge number is a complex process so to ease up the process, we will divide digit by digit. And store the remainder that follows. This process ...

Read More

Count changes in Led Lights to display digits one by one in C++

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

We are given a positive number let’s say num and the task is to calculate the count of changes in the Led lights displayed one by one. We will assume that initially all LEDs are off and they will be started based upon the string value.For solving this question we need to understand what a seven segment display is and its working.What are Seven Segment DisplaysSeven segment displays are the output display device that provide a way to display information in the form of image or text or decimal numbers which is an alternative to the more complex dot matrix ...

Read More

Program to find remainder when large number is divided by r in C++

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

In this problem, we are given a string num which is a large number and an integer R. Our task is to create a program to find remainder when large number is divided by r in C++.Problem Description − We need to find the remainder when the number defined by the string is divided by r which is a two-digit number.Let’s take an example to understand the problemInputnum = “123423450942121” r = 54Output7Solution ApproachTo find the remainder, we obviously need to divide the number. But dividing huge numbers is a complex process so to ease up the process, we will ...

Read More

Count common subsequence in two strings in C++

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

We are given two strings, let's say str1 and str2 containing characters and the task is to calculate the common subsequences in both the strings. In the below program we are using dynamic programming and for that we need to know what dynamic programming is and at what problems it can be used.Dynamic programming approach is similar to divide and conquer in breaking down the problem into smaller and yet smaller possible sub-problems. But unlike, divide and conquer, these subproblems are not solved independently. Rather, results of these smaller subproblems are remembered and used for similar or overlapping sub-problems.Dynamic programming ...

Read More

Program to find remainder without using modulo or % operator in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 2K+ Views

In this problem, we are given two numbers, N and D. Our task is to create a Program to find remainder without using modulo or % operator in C++.Problem description − We need to find the remainder that will be left after dividing the number N by D. But we cannot use the modulo or % operator for this.Let’s take an example to understand the problemInputN = 53 D = 3Output2Solution ApproachTo find the remainder, a simple approach is to find the number less than N which is the multiple of D. And the substrate the number from N. To ...

Read More

Count consonants in a string (Iterative and recursive methods) in C++

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

We are given a string with let’s say str of any length and the task is to calculate the count of consonants in the given string using both iterative and recursive methods.Consonants are those alphabets that are not vowel i.e alphabets except a, i, e, o, u are considered as consonants. So in the program below we need to find the count of alphabets other than these in string.The Recursion and Iteration both repeatedly execute the set of instructions. Recursion is when a statement in a function calls itself repeatedly. The iteration is when a loop repeatedly executes until the ...

Read More

Count half nodes in a Binary tree (Iterative and Recursive) in C++

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

We are given a binary tree and the task is to calculate the count of half nodes available in a binary tree using iterative and recursive approach. Half nodes are those nodes who have only one child and another child is null. Note that in half nodes we don't consider leaf nodes.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 ...

Read More

Count full nodes in a Binary tree (Iterative and Recursive) in C++

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

We are given a binary tree and the task is to calculate the count of full nodes available in a binary tree using iterative and recursive approach. Full nodes are those nodes who have both the children and no child is null. Note that in full nodes we consider nodes with exactly two children.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 ...

Read More

Count number of binary strings of length N having only 0's and 1's in C++

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

We are given a number let’s say, num and the task is to calculate the count of binary strings that can be formed through the given number num containing only o’s and 1’s.Binary Number System is one the type of Number Representation techniques. It is most popular and used in digital systems. Binary system is used for representing binary quantities which can be represented by any device that has only two operating states or possible conditions. For example, a switch has only two states: open or close.In the Binary System, there are only two symbols or possible digit values, i.e., ...

Read More

Program to find root of an equations using secant method in C++

Ayush Gupta
Ayush Gupta
Updated on 11-Mar-2026 1K+ Views

In this tutorial, we will be discussing a program to find the root of an equation using secant method.For this we will be provided with an equation. Our task is to find the roots of that equation using the iterative secant method.Example#include using namespace std; float f(float x) {    float f = pow(x, 3) + x - 1;    return f; } void secant(float x1, float x2, float E) {    float n = 0, xm, x0, c;    if (f(x1) * f(x2) < 0) {       do {          //calculating the intermediate ...

Read More
Showing 1451–1460 of 5,962 articles
« Prev 1 144 145 146 147 148 597 Next »
Advertisements