Server Side Programming Articles

Page 1524 of 2109

C++ Program to Check the Connectivity of Directed Graph Using BFS

Farhan Muhamed
Farhan Muhamed
Updated on 15-Apr-2025 964 Views

The Breadth-First Search (BFS) algorithm is a graph traversal algorithm that starts at the tree root and explores all nodes at the present depth before moving to the nodes at the next level. In this article, we will discuss how to check the connectivity of a directed graph using BFS traversal algorithm. Understanding Connectivity of a Graph A graph is said to be connected if there is a path between every pair of vertices. To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any ...

Read More

Why is the size of an empty class not zero in C++?

Ravi Ranjan
Ravi Ranjan
Updated on 15-Apr-2025 2K+ Views

The size of an empty class is not zero in C++ as it allocates one unique address to the object in the memory. The size can not be 0, because the two classes can not have the same memory address. So, the size of an empty class is 1 byte which does not hold any data, it is just for memory allocation. In this article, we will see an example of checking the size of an object of an empty class in C++. Demonstrating Size of an Empty Class In this approach, we have two C++ classes. One class ...

Read More

C++ Program to Find Minimum Element in an Array using Linear Search

Ravi Ranjan
Ravi Ranjan
Updated on 15-Apr-2025 1K+ Views

Linear search is a sequential searching algorithm where we traverse every element within the input array and compare it with the key element to be found. The minimum element refers to the smallest element in the array. In this article, we have an array of integers. Our task is to find the minimum element in that array using linear search. Here are the three approaches you can use to find the minimum element: Using Value Using Index Using Pointer Using Value In this approach, ...

Read More

C Program to print numbers from 1 to N without using semicolon

Ravi Ranjan
Ravi Ranjan
Updated on 15-Apr-2025 2K+ Views

Printing numbers from 1 to N is an easy task that can be achieved using loops, but to print numbers from one to N without using a semicolon is a tricky question. We will discuss two different methods to solve this question using iteration and recursion approaches. In this article, our task is to print numbers from 1 to 'n' and we don't have to use a semicolon. The approaches are listed below: Using Iteration Using Recursion Using Iteration This approach uses the iterative approach, where we have used the while loop to print the numbers from 1 to N. The num

Read More

C Program to sum the digits of a given number in single statement

Ravi Ranjan
Ravi Ranjan
Updated on 15-Apr-2025 673 Views

The calculation of the sum of the digits of a number in a single statement means that only one line of code will be doing the addition operation. The addition operation should not extend more than one statement. In this article, we have a number and our task is to calculate the sum of the digits of the number in a single statement in c. Here is a list of approaches: Using for Loop Using Recursive Function Using for Loop This approach uses a for loop to calculate the ...

Read More

C++ Program to Emulate N Dice Roller

Ravi Ranjan
Ravi Ranjan
Updated on 15-Apr-2025 1K+ Views

Emulating an n dice roller refers to rolling n number of dice simultaneously. In each roll, all the dice will return a different value from 1 to 6. In this article, we are having 'n' number of dices, our task is to emulate rolling n dices simultaneously. The approaches are mentioned below: Using Loop with rand() Function Using Recursion Using Loop with rand() Function In this approach, we have used the rand() function to generate a random value of dice in each roll. The srand() function with time() is ...

Read More

C++ Program to Check the Connectivity of Undirected Graph Using BFS

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Apr-2025 2K+ Views

The Breadth-First Search (BFS) algorithm is a graph traversal algorithm that starts at the tree root and explores all nodes at the present depth before moving to the nodes at the next level. In this article, we will discuss how to check the connectivity of a graph using BFS traversal algorithm. Understanding Connectivity of a Graph A graph is said to be connected if there is a path between every pair of vertices. To check connectivity of a graph, we will try to traverse all nodes using any traversal algorithm. After completing the traversal, if there is any ...

Read More

What should main() return in C and C++?

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 14-Apr-2025 4K+ Views

In C/C++, the main() function is used in the beginning of every program. This returns the program execution status in the operating system. Syntax Following is the syntax of the main() function using C/C++: int main(void); int main(int argc, char *argv[]); Example Below, the C/C++ example shows the usage of the main() return value. C C++ #include int main() { printf("Hello, C World!"); return 0; } Key Points of C Return 0: This is standard for successful execution Non-zero: It indicates error Implicit return: C99 allows omitting return #include int main() { std::cout

Read More

Convert a C++ String to Upper Case

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 11-Apr-2025 1K+ Views

In C++, converting a string into uppercase means changing all the characters into uppercase. This is a common requirement in many applications, such as formatting output, standard data input, and case sensitivity. Following is the table that shows the conversion of string to uppercase: String Case Characters Uppercase Characters ...

Read More

C++ Program to Convert Octal Number to Binary Number

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 11-Apr-2025 2K+ Views

In a computer system, the binary number is expressed in the binary numeral system while the octal number is in the octal numeral system. The binary number is in base 2 while the octal number is in base 8. Here, we provide the tabular data to understand binary numbers and their corresponding octal numbers as follows: Octal Number ...

Read More
Showing 15231–15240 of 21,090 articles
Advertisements