Hafeezul Kareem

Hafeezul Kareem

259 Articles Published

Articles by Hafeezul Kareem

Page 14 of 26

Divisible by 37 for large numbers in C++ Program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 293 Views

In this tutorial, we are going to write a program that checks whether the given large number is divisible by 37 or not.We are going to use a little bit of math here. Let's see the steps to solve the problem.Initialize the number.If the length of the given number is not divisible by 3, then add zeroes at the beginning of the number to make length is divisible by 3.Divide the number into 3 digits groups and add them.If the resultant sum is divisible by 37, then the given number is divisible by 37.If the resultant sum is 4 digits ...

Read More

Division without using '/' operator in C++ Program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 2K+ Views

In this tutorial, we are going to learn how to divide a number without using the division (/) operator.We have given two numbers, the program should return the quotient of the division operation.We are going to use the subtraction (-) operator for the division.Let's see the steps to solve the problem.Initialize the dividend and divisor.If the number is zero, then return 0.Store whether the result will be negative or not by checking the signs of dividend and divisor.Initialize a count to 0.Write a loop that runs until the number one is greater than or equals to the number two.Subtract the ...

Read More

Divisors of n-square that are not divisors of n in C++ Program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 169 Views

In this tutorial, we are going to write a program that finds the divisors count of n-square and not n.It's a straightforward problem. Let's see the steps to solve the problem.Initialize the number n.Initialize a counter for divisors.Iterate from 2 to n^2n2.If the n^2n2 is divisible by the current number and nn is not divisible by the current number, then increment the count.Print the count.ExampleLet's see the code.#include using namespace std; int getNumberOfDivisors(int n) {    int n_square = n * n;    int divisors_count = 0;    for (int i = 2; i

Read More

Double Base Palindrome in C++ Program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 408 Views

In this tutorial, we are going to write a program that checks whether the given number is a palindrome in two number systems.We have given a number and a base for another number system. We have to check whether the given number is a palindrome in the decimal number system and given number system.Let's see the steps to solve the problem.Initialize the number and number system base.Check whether the given number is a palindrome in the decimal number system or not.Convert the number into another number system in a string format.Check whether the converted number is palindrome or not.If the ...

Read More

Double ended priority queue in C++ Program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 798 Views

In this tutorial, we are going to create a double-ended priority queue using the set in c++.Let's see the steps to create a double-ended queue.Create a struct with a name as you wish.Create a variable for the queue using the set.size method that returns the size of the queue.is_empty method that returns whether the queue is empty or not.insert method to insert a new element into the queue.get_start method that returns an element from the left side of the queue.get_end method that returns the element from the right side of the queue.delete_start method that deletes the first element from the ...

Read More

Double the first element and move zero to end in C++ Program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 189 Views

In this tutorial, we are going to write a program that doubles the first element and moves all the zeroes to the end of the given array.We have to double a number when there are tow the same elements in adjacent indices. After that, we have to add a zero to the array.Move all the zeroes in the array to the end.ExampleLet's see the code.#include using namespace std; void moveZeroesToEnd(int arr[], int n) {    int count = 0;    for (int i = 0; i < n; i++) {       if (arr[i] != 0) {   ...

Read More

Double Tree with examples in C++ Program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 330 Views

In this tutorial, we are going to learn how to double the given tree.Let's see the steps to solve the problem.Create node class.Initialize the tree with dummy data.Write a recursive function to double the tree.Recursively traverse through the tree.Store the left node in a variable.After traversing add the data by creating a new node.Now, add the left node to the newly created node as a left child.Print the tree.ExampleLet's see the code.#include using namespace std; class node {    public:    int data;    node* left;    node* right; }; node* newNode(int data) {    node* Node = new ...

Read More

Create a linked list from two linked lists by choosing max element at each position in C++ Program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 2K+ Views

In this tutorial, we are going to write a program that creates a new linked list from the given linked lists.We have given two linked lists of the same size and we have to create a new linked list from the two linked lists with the max numbers from the two linked lists.Let's see the steps to solve the problem.Write a struct node.Create two linked lists of the same size.Iterate over the linked list.Find the max number from the two linked lists nodes.Create a new node with the max number.Add the new node to the new linked list.Print the new ...

Read More

Create a new string by alternately combining the characters of two halves of the string in reverse in C++ Program

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 192 Views

In this tutorial, we are going to write a program that creates a new string by alternately combining the characters of the two halves of the string in reverse order.Let's see the steps to solve the problem.Initialize the string.Find the length of the string.Store the first half and second half string indexes.Iterate from the ending of the two halves of the string.Add each character to the new string.Print the new string.ExampleLet's see the code.#include using namespace std; void getANewString(string str) {    int str_length = str.length();    int first_half_index = str_length / 2, second_half_index = str_length;    string new_string ...

Read More

Final string after performing given operations in C++

Hafeezul Kareem
Hafeezul Kareem
Updated on 11-Mar-2026 261 Views

In this tutorial, we are going to solve the following problem.Given a string containing only characters a and b, our task is to delete the sub-string ab from the string. And print the remaining string.Here, the idea is very simple to solve the problem. Every string with only a's and b's will shrink to either a's or b's at the end.Let's see the steps to solve the problem.Initialize the string.Initialize two counter variables for a and b.Iterate over the given string.Count the a's and b'sFind the maximum from the a and b frequencies.Print the difference between the two.ExampleLet's see the ...

Read More
Showing 131–140 of 259 articles
« Prev 1 12 13 14 15 16 26 Next »
Advertisements