Farhan Muhamed

Farhan Muhamed

No Code Developer, Vibe Coder

About

Professional Technical Content Writer, SEO Analyst and Software Developer specialized in web development and DSA in C++, Python.
Drop your queries and messages here: x.com/farhan

101 Articles Published

Articles by Farhan Muhamed

Page 5 of 11

C++ Program to print the diamond shape

Farhan Muhamed
Farhan Muhamed
Updated on 12-Jun-2025 759 Views

In this article, we will learn how to print a diamond shape with 2n rows and n columns for a given size n using C++. For example, if n = 4, the diamond shape will look like this: Algorithm to Print Diamond Shape To print the diamond shape, we can follow these steps: Take an integer input n from the user. To print upper half of the diamond, use a loop that runs from i = 1 to i

Read More

C++ Program to Check if any Graph is Possible to be Constructed for a Given Degree Sequence

Farhan Muhamed
Farhan Muhamed
Updated on 12-Jun-2025 231 Views

We are given an array of integers containing the degree of each vertex in a graph. Our task is to check if it is possible to construct a graph with the given degree sequence. Example: int degrees[] = {3, 2, 2, 0} Output: Not Possible Explanation: The first vertex has degree 3, which means it must be connected to three other vertices. But the last vertex has degree 0, meaning it cannot be connected to any other vertex. Hence, it is impossible to construct a graph with this degree sequence. To implement this in C++, we can ...

Read More

C++ Program to Demonstrate the Implementation of 4-Color Problem

Farhan Muhamed
Farhan Muhamed
Updated on 11-Jun-2025 873 Views

In this article, we will explain the 4 color problem to color a graph and implement the backtracking algorithm to solve it in C++. The 4 Color Problem The 4-color problem states that the maximum number of colors needed to color any planar graph (or a 2D map) is four, such that no two adjacent nodes have the same color. For example, suppose that you want to color a world map, such that no two countries sharing a border have the same color. According to this theorem, the maximum number of colors needed to do this is four. Now, ...

Read More

C++ Program to Solve the Dominating Set Problem

Farhan Muhamed
Farhan Muhamed
Updated on 10-Jun-2025 512 Views

In this article, we will explain the dominating set problem and implement it's solution in C++. First of all, let's understand what a dominating set is. Dominating Set of a Graph A dominating set for a graph is a subset of the set of all the vertices. Every vertex that is not in the dominating set should be adjacent of at least one vertex in the dominating set. To understand this clearly, consider the following graph: In the above graph, the set of vertices {B, D} is one of the dominating sets, because: ...

Read More

C++ Program to Generate a Random Subset by Coin Flipping

Farhan Muhamed
Farhan Muhamed
Updated on 10-Jun-2025 337 Views

The subsets of a set refers to all the possible combinations of choosing elements from the set. For example, if we have a set {1, 2}, the subsets are {}, {1}, {2}, and {1, 2}. In this article, we will learn how to generate a random subset for a set using coin flipping technique in C++. // Set of elements int arr[] = {1, 2, 3}; // Subsets of the above set {}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3} Coin Flipping Technique The coin flipping technique is a simple way ...

Read More

C++ Program to Implement the Binary Counting Method to Generate Subsets of a Set

Farhan Muhamed
Farhan Muhamed
Updated on 09-Jun-2025 1K+ Views

The subsets of a set refers to all the possible combinations of choosing elements from the set. For example, if we have a set {1, 2}, the subsets are {}, {1}, {2}, and {1, 2}. In this article, we will learn how to generate subsets of a set using the Binary Counting Method in C++. // Set of elements int arr[] = {1, 2, 3}; // Subsets of the above set {}, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3} Binary Counting Method The binary counting method is a technique used to generate ...

Read More

How to remove certain characters from a string in C++?

Farhan Muhamed
Farhan Muhamed
Updated on 09-Jun-2025 89K+ Views

In this section, we will see how to remove some characters from a string in C++. In C++ we can do this task very easily using erase() and remove() function. The remove function takes the starting and ending address of the string, and a character that will be removed. // Input String = "Hello TutorialsPoint" Char = 'o' // Output String = "Hell TutrialsPint" Algorithm to Remove Certain Characters from a String Here is the algorithm to remove certain characters from a string in C++: Step 1: Take a string and a character to be removed ...

Read More

What do single quotes do in C++ when used on multiple characters?

Farhan Muhamed
Farhan Muhamed
Updated on 06-Jun-2025 1K+ Views

Single quotes in C++ are used to denote characters, not strings. When you use single quotes around multiple characters or strings, C++ compiler will treat it as a multi-character literal, which will be stored as an integer value, representing the combined ASCII values of those characters. In this article, we will learn all about single quotes in C++ and how they behave when used with multiple characters. Single Quotes in C++ In C++, single quotes are used to represent a single character. For example, 'a' is a character literal representing the english alphabet 'a'. For each character, C++ assigns a ...

Read More

Why does std::getline() skip input after a formatted extraction?

Farhan Muhamed
Farhan Muhamed
Updated on 06-Jun-2025 598 Views

When using std::getline after a formatted extraction (like std::cin >>), you might see an unexpected behavior, where std::getline is skipping the next input line. In this article, we will understand why this happens and how to handle it. Getline skipping input after formatted extraction The code below shows how getline() is skipping input after a formatted extraction: #include #include using namespace std; int main() { string name; string city; cin

Read More

How to convert an enum type variable to a string in C++?

Farhan Muhamed
Farhan Muhamed
Updated on 06-Jun-2025 711 Views

Enum is a user-defined datatype in C++ that is used to assign names to integer values. For example, you can use an enum to represent the days of the week from 0 to 6, where 0 represents Sunday, 1 represents Monday, and so on. When you try to access a value of an enum, it will only return an integer value. In this article, we will learn how to convert an enum type variable to a string type variable in C++, so that we can easily display the enum value as a string. Example of Enum: enum color ...

Read More
Showing 41–50 of 101 articles
« Prev 1 3 4 5 6 7 11 Next »
Advertisements