Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 12 of 377

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

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 512 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 311 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

Power of Two in C

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

In C programming, checking whether a number is a power of two is a common problem that can be solved efficiently using bitwise operations. A power of two is any number that can be expressed as 2n where n is a non-negative integer (1, 2, 4, 8, 16, 32, etc.). Syntax bool isPowerOfTwo(int n); // Returns true if n is a power of 2, false otherwise Algorithm The key insight is that powers of two have a specific binary pattern − they have exactly one bit set to 1 (the MSB) and all other ...

Read More

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

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 383 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

Matrix Multiplication and Normalization in C program

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

In C programming, matrix multiplication and normalization are fundamental operations in linear algebra. Matrix multiplication follows specific rules where the number of columns in the first matrix must equal the number of rows in the second matrix. Matrix normalization scales each row so that its Euclidean norm equals 1. Syntax // Matrix Multiplication for (i = 0; i < rows1; i++) { for (j = 0; j < cols2; j++) { for (k = 0; k < cols1; k++) { ...

Read More

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

Arnab Chakraborty
Arnab Chakraborty
Updated on 15-Mar-2026 181 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

What are the differences between bitwise and logical AND operators in C/C++

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

In C, the bitwise AND (&) and logical AND (&&) operators serve different purposes and work with different data types. Understanding their differences is crucial for correct C programming. Syntax // Bitwise AND result = operand1 & operand2; // Logical AND result = condition1 && condition2; Bitwise AND Operator (&) The bitwise AND (&) operator performs a bit-by-bit AND operation between two integers. It works on integer types and returns the same data type. Each corresponding bit is AND-ed according to these rules − 1 & 1 = 1 ...

Read More
Showing 111–120 of 3,768 articles
« Prev 1 10 11 12 13 14 377 Next »
Advertisements