Server Side Programming Articles

Page 941 of 2109

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

Printing source of a C program itself

Sunidhi Bansal
Sunidhi Bansal
Updated on 15-Mar-2026 719 Views

In C programming, a self-printing program (also called a quine) is a program that prints its own source code as output. This can be achieved using the __FILE__ macro along with file I/O operations to read and display the current source file. Syntax FILE *fopen(__FILE__, "r"); The __FILE__ macro is a preprocessor macro that returns the name of the current source file as a string literal. This allows us to open and read our own source code at runtime. Example: Understanding __FILE__ Macro First, let's see how the __FILE__ macro works − ...

Read More

C Program for Round Robin scheduling

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

Round Robin is a CPU scheduling algorithm designed for time-sharing systems. It operates like FCFS scheduling but with a crucial difference − each process gets a fixed time slice called a time quantum. When a process's time quantum expires, it is preempted and moved to the back of the ready queue, allowing other processes to execute. What is Round Robin Scheduling? Round Robin treats the ready queue as a circular queue where each process gets a small unit of time (10-100 milliseconds typically). The main advantages include fair CPU allocation and good response time for interactive systems. The ...

Read More

Priority Queue using Linked List in C

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

A priority queue is a special type of queue where elements are served based on their priority rather than the order of insertion. In C, we can implement a priority queue using a linked list where each node contains data, priority, and a pointer to the next node. In a priority queue, elements with higher priority (lower numerical value) are processed first. If two elements have the same priority, they follow FIFO order. Syntax typedef struct node { int data; int priority; struct node* ...

Read More

C Program for FCFS Scheduling

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

We are given with the n number of processes i.e. P1, P2, P3, ..., Pn and their corresponding burst times. The task is to find the average waiting time and average turnaround time using FCFS CPU Scheduling algorithm. What is Waiting Time and Turnaround Time? Turnaround Time is the time interval between the submission of a process and its completion. Turnaround Time = completion of a process − submission of a process Waiting Time is the difference between turnaround time and burst time Waiting Time = turnaround time − burst time What is FCFS Scheduling? ...

Read More

C Program for focal length of a lens

Sunidhi Bansal
Sunidhi Bansal
Updated on 15-Mar-2026 478 Views

In optics, the focal length is a fundamental property of lenses that determines their converging or diverging power. Given the image distance and object distance from a lens, we can calculate the focal length using the lens equation. What is Focal Length? Focal length of an optical system is the distance between the center of lens or curved mirror and its focus. It represents the distance over which initially collimated rays are brought to a focus. ...

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

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

C Program Coin Change

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

In this problem, we are given a value n, and we want to make change of n rupees using a given set of coin denominations. We need to return the total number of ways to make the sum using these coins. Syntax int coinChange(int coins[], int numCoins, int amount); Example Input/Output Input: N = 6, coins = {1, 2, 4} Output: 6 Explanation: The total combinations that make the sum of 6 are: {1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 2}, {1, 1, 2, 2}, {1, 1, 4}, {2, 2, ...

Read More

C / C++ Program for Dijkstra\'s shortest path algorithm

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

Dijkstra's algorithm is a greedy algorithm used to find the shortest path from a source vertex to all other vertices in a weighted graph. It works by maintaining a set of vertices whose shortest distance from the source has been determined and gradually expanding this set until all vertices are included. Syntax void dijkstra(int graph[V][V], int source); Algorithm Steps Step 1: Create a set to store vertices included in shortest path tree Step 2: Initialize all distances as INFINITE and source distance as 0 Step 3: Loop until all vertices are processed: ...

Read More
Showing 9401–9410 of 21,090 articles
« Prev 1 939 940 941 942 943 2109 Next »
Advertisements