C++ Articles

Page 5 of 597

C vs BASH Fork bomb in C/C++?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 522 Views

A fork bomb is a type of denial-of-service attack that creates an exponential number of processes, consuming system resources. While BASH fork bombs are more persistent because created processes detach from the parent, C fork bombs have their own characteristics and can be modified to increase their impact. Syntax #include int main() { while(1) { fork(); } return 0; } BASH vs C Fork Bomb Differences The key differences between BASH and ...

Read More

AA Trees in C/C++?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 2K+ Views

An AA tree in computer science is defined as a form of balanced binary search tree designed for storing and retrieving ordered data efficiently. AA trees are a variation of red-black trees but with simplified balancing rules. Unlike red-black trees, red nodes (horizontal links) in AA trees can only exist as right children, never left children. Key Properties AA trees maintain the following invariants − The level of every leaf node is one The level of every left child is exactly one smaller than its parent The level of every right child is equal to or ...

Read More

A-Buffer Method in C/C++?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 2K+ Views

The A-Buffer method is an advanced hidden surface removal technique in computer graphics that extends the traditional Z-Buffer algorithm. Also known as anti-aliased, area-averaged, or accumulation buffer, this technique handles both opaque and transparent objects, making it suitable for complex rendering scenarios where multiple surfaces contribute to a single pixel. Syntax struct ABuffer { float depth; union { struct { int r, g, b; ...

Read More

A Number Link Game in C/C++?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 315 Views

The Number Link Game is a logic puzzle played on an n × n grid. Some squares are empty, some are solid (blocked), and some contain numbered endpoints (1, 2, 3, etc.). Each number appears exactly twice on the board. The goal is to connect matching numbers with non-intersecting paths using only horizontal and vertical movements, filling all non-solid squares. Syntax // Union-Find structure for path generation typedef struct { int parent[MAX_SIZE]; int rank[MAX_SIZE]; } UnionFind; // Game board representation typedef struct { int ...

Read More

System() Function in C/C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 15-Mar-2026 38K+ Views

The system() function is a part of the C standard library that executes system commands. It is used to pass commands that can be executed in the command processor or terminal of the operating system, and returns the command's exit status after completion. Note: To use the system() function, include header file. Syntax int system(const char *command); Parameters command − A pointer to a null-terminated string containing the command to be executed. If NULL, checks if command processor is available. Return Value Returns the exit ...

Read More

Why is a[i] == i[a] in C/C++ arrays?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 398 Views

In C programming, there's an interesting feature where array subscript notation a[i] can also be written as i[a]. This happens because of how C internally handles array indexing through pointer arithmetic. Syntax a[i] == i[a] // Both expressions are equivalent How It Works In C, E1[E2] is defined as (*((E1) + (E2))). The compiler performs pointer arithmetic internally to access array elements. Because the binary + operator is commutative, a[i] becomes *(a + i), and i[a] becomes *(i + a). Since addition is commutative, both expressions evaluate to the same memory ...

Read More

How to sort an array of dates in C/C++?

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 1K+ Views

In C programming, sorting an array of dates requires creating a structure to represent dates and implementing a custom comparison function. We use the qsort() function from the standard library to sort the array based on chronological order. Syntax void qsort(void *base, size_t num, size_t size, int (*compare)(const void *, const void *)); Method 1: Using qsort() with Custom Comparator This approach uses a structure to store date components and a comparison function that compares dates chronologically − #include ...

Read More

C / C++ Program for Subset Sum (Backtracking)

sudhir sharma
sudhir sharma
Updated on 15-Mar-2026 12K+ Views

Backtracking is a technique to solve dynamic programming problems. It works by going step by step and rejects those paths that do not lead to a solution and trackback (moves back) to the previous position. In the subset sum problem, we have to find the subset of a set such that the elements of this subset sum up to a given number K. All the elements of the set are positive and unique (no duplicate elements are present). Syntax void subset_sum(int s[], int t[], int s_size, int t_size, int sum, int index, int target_sum); ...

Read More

Process Synchronization in C/C++

Sunidhi Bansal
Sunidhi Bansal
Updated on 15-Mar-2026 7K+ Views

Process synchronization is the technique to overcome the problem of concurrent access to shared data which can result in data inconsistency. A cooperating process is the one which can affect or be affected by other process which will lead to inconsistency in processes data therefore Process synchronization is required for consistency of data. Syntax /* General structure for process synchronization */ do { entry_section(); critical_section(); exit_section(); remainder_section(); } while(1); The Critical-Section Problem Every process has a reserved segment ...

Read More

Code valid in both C and C++ but produce different output

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 191 Views

Here we will see programs that return different results when compiled with C or C++ compilers. These differences arise due to fundamental variations in how C and C++ handle certain language features. Character Literal Size Differences In C, character literals like 'a' are treated as int type, while in C++ they are treated as char type. This affects the result of the sizeof() operator − Example 1: C Code #include int main() { printf("Character: %c, Size: %d bytes", 'a', sizeof('a')); return 0; } ...

Read More
Showing 41–50 of 5,962 articles
« Prev 1 3 4 5 6 7 597 Next »
Advertisements