Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Articles
Page 920 of 2547
largest string formed by choosing words from a given Sentence as per given Pattern
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 MoreFind the count of Alphabetic and Alphanumeric strings from given Array of Strings
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 MoreCount of sum of “10” subsequences for each 1 in string with A 1s, B 10s and C 0s
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 MoreConvert a string Str1 to Str2 by moving B to right and A to left without crossover
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 MoreC Program To Write Your Own atoi()
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 MoreProducer-Consumer Problem in C
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 MoreC Program to Find Minimum Insertions to Form a Palindrome
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 MoreDTH Sensor Programming
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 MoreHow Much Java is Better than C?
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 MoreLocate unused structures and structure-members
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