Programming Articles

Page 920 of 2547

largest string formed by choosing words from a given Sentence as per given Pattern

Ravi Ranjan
Ravi Ranjan
Updated on 15-Mar-2026 421 Views

To find the largest string formed by choosing words from a given sentence, a user should know about the lexicographically largest string. A lexicographically largest string is a string, when sorted alphabetically, it would appear at the last if we form all possible strings from the selected words. For example: {lion, zebra, apple} will be lexicographically sorted as {apple, lion, zebra}. In this article, we have been given a string and a pattern. Based on this pattern, we have to find the lexicographically largest string matching the given pattern by choosing words from the sentence using C. Here is ...

Read More

Find the count of Alphabetic and Alphanumeric strings from given Array of Strings

Thanweera Nourin A V
Thanweera Nourin A V
Updated on 15-Mar-2026 523 Views

In C programming, counting alphabetic and alphanumeric strings from an array involves checking each character in every string. An alphabetic string contains only letters (a-z, A-Z), while an alphanumeric string contains both letters and digits (0-9). Syntax int isAlphabetic(char str[]); int isAlphanumeric(char str[]); void countStrings(char arr[][MAX_LEN], int n); Algorithm The approach to solve this problem involves the following steps − Step 1 − Iterate through each string in the array Step 2 − Check each character to determine if string is alphabetic or alphanumeric Step 3 − Count occurrences and maintain frequency ...

Read More

Count of sum of “10” subsequences for each 1 in string with A 1s, B 10s and C 0s

Thanweera Nourin A V
Thanweera Nourin A V
Updated on 15-Mar-2026 298 Views

In C programming, we need to find the count of "10" subsequences for each '1' in a string that contains A individual 1s, B "10" substrings, and C individual 0s. This problem involves counting subsequences where each '1' can pair with available '0' characters. Syntax long long maximumSubSeq(int A, int B, int C); Problem Understanding Given three parameters − A − Number of standalone '1' characters B − Number of "10" substrings C − Number of standalone '0' characters We need to count all possible "10" subsequences from the concatenated string. ...

Read More

Convert a string Str1 to Str2 by moving B to right and A to left without crossover

Thanweera Nourin A V
Thanweera Nourin A V
Updated on 15-Mar-2026 312 Views

The aim of this article is to implement a program to convert a string Str1 to Str2 by moving B to right and A to left without crossover. In this problem, we have two strings where characters 'A' can only move left, characters 'B' can only move right, and empty spaces are represented by '#'. The key constraint is that 'A' and 'B' characters cannot cross over each other during movement. Syntax bool moveRobots(char str1[], char str2[]); Examples Example 1 Input: str1 = "#B#A#", str2 = "##BA#" Output: Yes ...

Read More

C Program To Write Your Own atoi()

Thanweera Nourin A V
Thanweera Nourin A V
Updated on 15-Mar-2026 894 Views

The atoi() function in C converts a string representation of a number into an integer value. The name stands for "ASCII to Integer". While the standard library provides atoi(), implementing your own version helps understand string parsing and character-to-number conversion. Syntax int myAtoi(const char *str); Parameters str − Pointer to the null-terminated string to be converted Return Value Returns the converted integer value. If no valid conversion can be performed, it returns 0. Example 1: Basic Implementation This example shows a simple implementation that handles positive numbers − ...

Read More

Producer-Consumer Problem in C

Way2Class
Way2Class
Updated on 15-Mar-2026 30K+ Views

The producer-consumer problem is a classic synchronization challenge in concurrent programming where multiple threads share a common buffer. Producers generate data and place it into the buffer, while consumers remove and process data from the buffer. The main challenge is coordinating these operations to prevent race conditions and ensure data integrity. Syntax /* Basic structure for producer-consumer implementation */ pthread_t producer_thread, consumer_thread; pthread_mutex_t mutex; pthread_cond_t condition_variable; void* producer(void* arg); void* consumer(void* arg); Problem Statement The producer-consumer problem involves two types of processes − Producer − Generates data and puts it into ...

Read More

C Program to Find Minimum Insertions to Form a Palindrome

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 524 Views

A palindrome is a string that reads the same forwards and backwards. Given a string, we need to find the minimum number of character insertions required to make it a palindrome. We will explore three approaches − recursive, memoization, and dynamic programming. Syntax int minInsertions(char str[], int start, int end); Method 1: Recursive Approach The recursive approach compares characters from both ends. If they match, we move inward; otherwise, we try inserting at either end and take the minimum ? #include #include #include int findMin(int a, int b) ...

Read More

DTH Sensor Programming

Saba Hilal
Saba Hilal
Updated on 15-Mar-2026 2K+ Views

DHT11 and DHT22 sensors are digital sensors that can measure temperature and humidity. The DHT22 is more expensive but offers better accuracy and wider temperature ranges compared to DHT11. These sensors communicate with microcontrollers like ESP32 using a single−wire digital protocol. Syntax #include "DHT.h" #define DHT_PIN pin_number #define DHT_TYPE DHT11 // or DHT22 DHT sensor_object(DHT_PIN, DHT_TYPE); DHT11 Specifications Parameter DHT11 DHT22 Temperature Range 0°C to 50°C −40°C to 80°C Humidity Range 20% to 80% 0% to 100% Temperature Accuracy ±2°C ±0.5°C Humidity Accuracy ...

Read More

How Much Java is Better than C?

Mr. Satyabrata
Mr. Satyabrata
Updated on 15-Mar-2026 680 Views

Java and C are two popular programming languages with different features, syntax, and applications. Java was first introduced by Sun Microsystems in 1995 and operates on the Java Virtual Machine (JVM). C is a procedural programming language developed by Dennis Ritchie at Bell Labs in 1972. Both Java and C have their pros and cons, but here we will explore how Java is better than C in various aspects. Memory Management One of the notable distinctions between Java and C is in memory management. C uses manual memory management, which requires the programmer to allocate and deallocate memory ...

Read More

Locate unused structures and structure-members

Satish Kumar
Satish Kumar
Updated on 15-Mar-2026 1K+ Views

Structures in C are user-defined data types that group related variables together. As codebases grow, some structures and their members may become unused, leading to cluttered code and wasted memory. This article explores methods to identify and remove unused structures and structure members in C programs. Syntax struct structure_name { data_type member1; data_type member2; // ... more members }; Why Remove Unused Structures and Members? Unused structures and members can impact performance and readability of your code. Here are some reasons why ...

Read More
Showing 9191–9200 of 25,466 articles
« Prev 1 918 919 920 921 922 2547 Next »
Advertisements