Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 11 of 377

fillpoly() function in C

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

The fillpoly() function in C is part of the graphics.h library and is used to draw and fill a polygon with the current fill pattern and color. It takes the same arguments as drawpoly() but additionally fills the interior of the polygon. Syntax void fillpoly(int numpoints, int *polypoints); Parameters numpoints − Specifies the number of points in the polygon polypoints − Pointer to an array containing x, y coordinates of each point The polypoints array should contain numpoints * 2 integers, where each pair represents the x and y coordinates of ...

Read More

Flood fill algorithm using C graphics

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

The flood fill algorithm is a technique used to fill a connected region with a specific color. It starts from a seed pixel and recursively fills all adjacent pixels that have the same color as the original pixel. Syntax void floodFill(int x, int y, int newColor, int oldColor); Note: This example requires Turbo C/C++ or a compatible graphics library with graphics.h support. Modern compilers may need additional setup for graphics functions. Algorithm Steps The flood fill algorithm follows these steps − Check if the current pixel coordinates are within ...

Read More

Find the Longest Substring Containing Vowels in Even Counts in C++

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

The problem of finding the longest substring with vowels appearing an even number of times can be solved efficiently using bit manipulation and prefix sums. We need to track the parity (odd/even count) of each vowel ('a', 'e', 'i', 'o', 'u') as we traverse the string. Syntax int findLongestSubstring(char* s); Algorithm Steps The approach uses a bitmask to represent the parity state of vowels − Use a 5-bit mask where each bit represents parity of vowels a, e, i, o, u Store the first occurrence of each mask state When a mask ...

Read More

Integer to Roman in C

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

Given a decimal number n, we have to convert this into Roman numeral. The value n lies in the range 1 to 4000. Roman numerals use specific symbols and follow subtraction rules for certain combinations. Number Numeral 1 I 4 IV 5 V 9 IX 10 X 40 XL 50 L 90 XC 100 C 400 CD 500 D 900 CM 1000 M 4000 MMMM ...

Read More

C program for file Transfer using UDP?

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

File transfer using UDP in C enables transferring files between client and server using User Datagram Protocol. This implementation includes XOR encryption for basic security and handles file existence checking. Syntax int socket(int domain, int type, int protocol); int sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); int recvfrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); Algorithm The server starts and waits for a filename from the client. The client sends a filename to the server. The server receives the filename ...

Read More

Binary Number System - Overflow in Arithmetic Addition in C/C++?

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

The 2's complement number system is widely implemented in computer architecture for representing signed integers. In an N-bit 2's complement system, numbers can be represented from -2n-1 to 2n-1 - 1. For example − 4-bit system represents numbers from -8 to 7 5-bit system represents numbers from -16 to 15 Overflow occurs when adding two N-bit 2's complement numbers and the result is too large to fit into the N-bit representation. Syntax // Overflow detection formula overflow = carry_in_msb ^ carry_out_msb Understanding Overflow A computer uses N-bit fixed registers. ...

Read More

Barabasi Albert Graph (for Scale Free Models) in C/C++?

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

The Barabási-Albert model is one of the most important models for generating scale-free networks. It combines two fundamental concepts: growth and preferential attachment. Growth means that the number of nodes in the network increases over time, while preferential attachment means that highly connected nodes are more likely to receive new connections. This model simulates real-world networks where popular nodes (like well-known websites or influential people) attract more connections than less popular ones, following the "rich get richer" principle. Syntax // Basic structure for BA model implementation typedef struct { int **adjacencyMatrix; ...

Read More

Arrange a binary string to get maximum value within a range of indices C/C++?

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

In this problem, we have a binary string consisting of only 0's and 1's, along with M non-intersecting ranges [A1, B1], [A2, B2], ..., [AM, BM]. We need to rearrange the string to maximize the sum within the given ranges while ensuring the result is lexicographically maximum. Syntax char* arrangeString(char* binaryStr, int ranges[][2], int m); Algorithm The approach involves two main steps − First, fill all the given ranges with 1's to maximize the sum Then, place remaining 1's from left to right to achieve lexicographical maximum Example 1: Basic ...

Read More

An application on Bertrandís ballot theorem in C/C++

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

Bertrand's ballot theorem states that in an election where candidate A receives p votes and candidate B receives q votes (where p > q), the probability that A is always strictly ahead throughout the counting process is (p-q)/(p+q). This theorem has practical applications in probability theory and combinatorics. Syntax Probability = (p - q) / (p + q) where p > q > 0 Mathematical Example Let there are 5 voters, of whom 3 vote for candidate A and 2 vote for candidate B (so p = 3 and q = 2). Ten possibilities ...

Read More

All combinations of strings that can be used to dial a number in C/C++?

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

Given a phone number, this program generates all possible string combinations that can be formed using the traditional phone keypad mapping. Each digit (2-9) maps to multiple letters, while digits 0 and 1 map to themselves. Syntax void printWords(int number[], int n); Keypad Mapping 2 ABC 3 DEF 4 GHI 5 JKL ...

Read More
Showing 101–110 of 3,768 articles
« Prev 1 9 10 11 12 13 377 Next »
Advertisements