Server Side Programming Articles

Page 937 of 2109

How arrays are passed to functions in C/C++

Ayush Gupta
Ayush Gupta
Updated on 15-Mar-2026 236 Views

In this tutorial, we will be discussing how arrays are passed to functions in C. Understanding this concept is crucial for proper array handling in C programming. In C, arrays are never passed by value to functions. Instead, when you pass an array to a function, what actually gets passed is a pointer to the first element of the array. This is called "array decay" − the array name decays into a pointer. Syntax // Method 1: Array notation void function_name(data_type array_name[]); // Method 2: Pointer notation void function_name(data_type *array_name); // Method ...

Read More

Predefined Identifier __func__ in C

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

The __func__ is a predefined identifier in C that provides the name of the current function. It was introduced in C99 standard and is automatically available in every function without any declaration. Syntax __func__ The __func__ identifier is implicitly declared as if the following declaration appears at the beginning of each function − static const char __func__[] = "function-name"; Example 1: Basic Usage Here's a simple example showing how __func__ returns the current function name − #include void function1(void) { printf("Current function: ...

Read More

Print * in place of characters for reading passwords in C

sudhir sharma
sudhir sharma
Updated on 15-Mar-2026 685 Views

In C programming, when handling passwords, it's important to hide the actual characters from being displayed on screen for security reasons. This involves replacing each character of the password with an asterisk (*) symbol. Let's take an example to understand the problem − Input: password Output: ******** Syntax for(int i = 0; i < strlen(password); i++){ printf("*"); } Example 1: Using Predefined Password String The below program demonstrates how to replace each character of a password string with asterisks ? #include #include ...

Read More

Print 1 2 3 infinitely using threads in C

sudhir sharma
sudhir sharma
Updated on 15-Mar-2026 594 Views

In C programming, we can print the sequence "1 2 3" infinitely using multiple threads with proper synchronization. This demonstrates thread coordination using mutexes and condition variables to ensure orderly execution. Syntax pthread_create(&thread_id, NULL, thread_function, argument); pthread_mutex_lock(&mutex); pthread_cond_wait(&condition, &mutex); pthread_cond_signal(&condition); pthread_mutex_unlock(&mutex); Installation: On Linux systems, compile with: gcc filename.c -lpthread Example This program creates three threads that print numbers 1, 2, and 3 in sequence infinitely. Each thread waits for its turn using condition variables − #include #include pthread_cond_t cond1 = PTHREAD_COND_INITIALIZER; pthread_cond_t cond2 = PTHREAD_COND_INITIALIZER; ...

Read More

Print 2D matrix in different lines and without curly braces in C/C++

sudhir sharma
sudhir sharma
Updated on 15-Mar-2026 336 Views

Here, we will see how to print a 2D matrix in C programming language without using curly braces. This technique uses a clever approach to eliminate the need for braces in nested loops. Curly braces are separators in C that define separate code blocks in the program. Without curly braces, defining scopes is difficult, but we can use a shorthand technique to achieve the same result for simple operations. Syntax for (int i = 0; i < rows; i++) for (int j = 0; j < cols; j++) ...

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 368 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 311 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
Showing 9361–9370 of 21,090 articles
« Prev 1 935 936 937 938 939 2109 Next »
Advertisements