Server Side Programming Articles

Page 961 of 2109

Print the string after the specified character has occurred given no. of times in C Program

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

In C programming, we often need to extract a substring after a specific character has occurred a certain number of times. This task involves scanning through a string and printing all characters after the nth occurrence of a specified character. Syntax for (i = 0; i < string_length; i++) { if (count > 0) { if (string[i] == target_char) { count--; } ...

Read More

C Program for Print the pattern by using one loop

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

In C programming, printing patterns using a single loop is an interesting challenge that demonstrates the creative use of loop control statements like continue. This approach combines the functionality of nested loops into one loop by manipulating loop variables and using conditional statements. Syntax for (initialization; condition; ) { // Logic with continue statement // Manual increment of loop variable } Algorithm START Step 1 → Declare variables i and j to 0 with number of rows n = 6 Step 2 → Loop For i=1 and i

Read More

Print triplets with sum less than or equal to k in C Program

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

Given an array with a set of elements, the task is to find all triplets (sets of exactly three elements) having sum less than or equal to a given value k. Input − arr[] = {1, 2, 3, 8, 5, 4}, k = 10 Output − triplets → {1, 2, 3} {1, 2, 5} {1, 2, 4} {1, 3, 5} {1, 3, 4} {1, 5, 4} {2, 3, 5} {2, 3, 4} Syntax for (i = 0; i < size-2; i++) { for (j = i+1; j < size-1; j++) { for (k = j+1; k < size; k++) { if (arr[i] + arr[j] + arr[k]

Read More

Print longest palindrome word in a sentence in C Program

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

In C programming, finding the longest palindrome word in a sentence involves parsing individual words and checking if they read the same forwards and backwards. A palindrome is a word that remains identical when its characters are reversed. What is a Palindrome? A palindrome is a word or sequence that reads the same backward as forward. For example, "malayalam" is a palindrome because reversing it gives "malayalam" − the same word. Examples of palindromes: radar, level, madam, racecar Syntax int isPalindrome(char word[], int start, int end); void findLongestPalindrome(char sentence[]); Algorithm The ...

Read More

Print n 0s and m 1s such that no two 0s and no three 1s are together in C Program

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

In C programming, we need to print a sequence of N zeros and M ones such that no two zeros are consecutive and no three ones are consecutive. This is a constraint satisfaction problem that requires careful arrangement of digits. Syntax // Condition to check if sequence is possible if ((m < n-1) || m >= 2 * (n + 1)) // Sequence not possible else // Generate valid sequence Algorithm The algorithm works in three main cases − Case 1: When m = ...

Read More

C Program for Print individual digits as words without using if or switch.

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

In C programming, converting individual digits of a number to their corresponding words is commonly done using if-else or switch statements. However, we can achieve this more elegantly using an array of string pointers to map each digit (0-9) to its word representation. Syntax char *digitWords[] = {"ZERO", "ONE", "TWO", ..., "NINE"}; // Access digit word using: digitWords[digit] Algorithm START Step 1 → Declare int variables num, i and array of pointers char *alpha with values {"ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE"} Step 2 → Read or assign the ...

Read More

Print first k digits of 1/n where n is a positive integer in C Program

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

In C programming, we need to find the first k digits of the decimal representation of 1/n without using floating-point arithmetic. This involves simulating the long division process using integer operations only. Syntax // Basic approach using modular arithmetic for(i = 0; i < k; i++) { digit = (10 * remainder) / n; remainder = (10 * remainder) % n; } Algorithm The algorithm simulates manual long division − Step 1: Initialize remainder = 1 (representing the dividend "1") Step 2: For each ...

Read More

Print multiples of Unit Digit of Given Number in C Program

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

In C programming, finding multiples of the unit digit of a given number involves extracting the last digit and then finding all numbers that divide it evenly. The unit digit of any number can be obtained using the modulo operator (%) with 10. Syntax int unitDigit = number % 10; Algorithm START Step 1 → Declare variables num, unitDigit and i Step 2 → Input number num Step 3 → Store num%10 in unitDigit to fetch unit digit Step 4 → Print unitDigit Step 5 → Loop for i=2 and i

Read More

Area of a square inscribed in a circle which is inscribed in an equilateral triangle in C Program?

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

The program finds the area of a square inscribed in a circle which is inscribed in an equilateral triangle. When a circle is inscribed in an equilateral triangle of side length a, the radius of the circle is a/(2√3). The diameter of the inscribed circle becomes the diagonal of the square: d = 2 * r = a/√3. Using the formula for the area of a square given its diagonal (1/2) * d², we get: Area = (1/2) * (a²/3) = a²/6. ...

Read More

C vs BASH Fork bomb?

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

A fork bomb is a Denial of Service (DoS) attack that exploits the fork() system call to create an exponentially growing number of processes, eventually exhausting system resources. Both BASH and C can implement fork bombs, but they work differently. Syntax pid_t fork(void); BASH Fork Bomb The classic BASH fork bomb is a compact one-liner − :(){ :|: & };: This code works as follows: :() − Defines a function named : { :|: & } − Function body that pipes itself to itself and runs in background ...

Read More
Showing 9601–9610 of 21,090 articles
« Prev 1 959 960 961 962 963 2109 Next »
Advertisements