Server Side Programming Articles

Page 904 of 2109

C program to find sum and difference using pointers in function

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

In C programming, functions can return only one value at a time. However, when we need to calculate multiple results like sum and difference of two numbers, we can use pointers as function parameters. This technique allows us to modify the original variables directly through their memory addresses. Syntax void functionName(int *ptr1, int *ptr2); // Call the function functionName(&variable1, &variable2); Algorithm To solve this problem, we will follow these steps − Define a function that takes addresses of two variables as parameters Store the sum in a temporary variable Calculate the difference ...

Read More

C program to find maximum of four integers by defining function

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

In C programming, we can find the maximum of four integers by defining our own function. We create a max() function that compares two numbers and returns the larger one, then use it repeatedly to find the maximum among all four numbers. So, if the input is like a = 5, b = 8, c = 2, d = 3, then the output will be 8. Syntax int max(int x, int y); Algorithm To solve this, we will follow these steps − Define a function max() that takes two integers x ...

Read More

C program to find sum and difference of two numbers

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

In C programming, finding the sum and difference of two numbers is a fundamental operation. This program demonstrates how to perform arithmetic operations on different data types and handle the output formatting correctly based on the operands' types. Syntax // For integer arithmetic int result = num1 + num2; int result = num1 - num2; // For floating-point arithmetic float result = num1 + num2; float result = num1 - num2; Example 1: Sum and Difference of Integer Numbers This example shows basic arithmetic operations on integer values − ...

Read More

C Program to read and write character string and sentence

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

In C programming, reading different types of input requires different functions. Reading a single character uses scanf() with %c, strings without spaces use scanf() with %s, and sentences with spaces require fgets() for proper handling. Syntax // Character input scanf("%c", &character); // String input (no spaces) scanf("%s", string); // Sentence input (with spaces) fgets(sentence, size, stdin); Example This program demonstrates reading a character, string, and sentence from user input − #include int main() { char character; char string[500]; ...

Read More

What are the special symbols in C language?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 65K+ Views

In C programming language, special symbols have specific meanings and are essential for writing syntactically correct programs. This language provides low-level access to memory and is known for its performance and efficiency. The C language includes a character set of English alphabets (a-z, A-Z), digits (0-9), and special characters with specific meanings. Some special characters are operators, while combinations like "" are escape sequences. In C, symbols are used to perform special operations − Syntax [] () {} , ; * = # : . -> + - / % < > ! & | ^ ...

Read More

How to convert binary to Hex by using C language?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 11K+ Views

Binary numbers are represented using only 1's and 0's. Hexadecimal numbers use 16 digits: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F} where A=10, B=11, C=12, D=13, E=14, F=15. Syntax // Convert binary string to decimal first, then to hex int binaryToDecimal(long binary); void decimalToHex(int decimal, char hex[]); Converting Binary to Hex Process To convert binary to hexadecimal, group the binary digits into 4-bit blocks (nibbles) from right to left. Each 4-bit group represents one hexadecimal digit − Binary: 1110 0101 1011 ...

Read More

C program to insert a node at any position using double linked list

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 2K+ Views

A doubly linked list is a linear data structure where each node contains data and two pointers − one pointing to the previous node and another to the next node. This allows traversal in both directions and efficient insertion/deletion operations at any position. Syntax struct node { int data; struct node *prev; struct node *next; }; void insertAtPosition(int data, int position); Doubly Linked List Structure The doubly linked list structure consists of nodes where each node has three components − ...

Read More

C program to print Excel column titles based on given column number

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 873 Views

In C programming, converting a column number to its corresponding Excel column title is a common problem. Excel columns are labeled as A, B, C, ..., Z, AA, AB, AC, and so on. This follows a base-26 numbering system where A=1, B=2, ..., Z=26, AA=27, etc. Syntax char* convertToExcelTitle(int columnNumber); Algorithm The algorithm works by repeatedly dividing the column number by 26 and converting the remainder to the corresponding character − Subtract 1 from the column number to make it 0-indexed Find the remainder when divided by 26 and convert to character ...

Read More

C program to represent numbers in numerator and denominator in string format

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 1K+ Views

In C, we can convert fractions to their decimal string representation using dynamic memory allocation. This program handles both terminating and repeating decimal fractions, representing repeating decimals with parentheses. Syntax char* fractionToDecimal(int numerator, int denominator); Algorithm The algorithm works by performing long division and tracking remainders to detect repeating cycles − Calculate the integer part using division Use the remainder to compute decimal digits Store each remainder to detect when a cycle begins Mark repeating portions with parentheses Example Following is the C program to represent fractions in decimal ...

Read More

What is strtok_r() function in C language?

Bhanu Priya
Bhanu Priya
Updated on 15-Mar-2026 4K+ Views

The strtok_r() function is a thread-safe alternative to the strtok() function for tokenizing strings. The "_r" suffix stands for "re-entrant, " meaning this function can be safely interrupted and resumed without losing its state. This makes it ideal for multi-threaded applications where multiple threads might need to tokenize strings simultaneously. A re-entrant function can be interrupted during execution and safely resumed later. Because strtok_r() maintains its context through an external pointer, it avoids the static variable issues that make strtok() non-thread-safe. Syntax char *strtok_r(char *str, const char *delim, char **saveptr); Parameters str ...

Read More
Showing 9031–9040 of 21,090 articles
« Prev 1 902 903 904 905 906 2109 Next »
Advertisements