Found 34489 Articles for Programming

Count pairs of characters in a string whose ASCII value difference is K

Sonal Meenu Singh
Updated on 31-Jul-2023 19:50:15

86 Views

In this tutorial, we learn how to count the character pair in a string whose ASCII value is the difference of K. K is any difference value, it can be either 1 or 0. Create a C++ code to count such character pairs in an input string S. We used the size() method of the String class Syntax size() = It is a String class method. It is an empty parameter library method. It returns the size of the string in terms of bytes. string_name.size() Example = s.size() ASCII values are predefined values for characters, symbols, ... Read More

Count of three non-overlapping substrings which on concatenation forms a palindrome

Sonal Meenu Singh
Updated on 31-Jul-2023 19:48:53

93 Views

Introduction In this tutorial, we will elaborate an approach for finding three non-overlapping substrings from a given string s, and when all substrings are combined together they form a palindrome. To solve this task we use the string class features of the C++ programming language. Palindrome in a string means the string reads the same in both forward and backward directions. The palindrome string example is Madam. Suppose there is a string "s" and the substrings are a, b, and c. When you combine a, b, and c, they form a palindrome string. Here is an example to understand the ... Read More

Double floatValue() in Java with Examples

Way2Class
Updated on 31-Jul-2023 17:27:27

68 Views

When it comes to dealing with precision-based calculations, Java provides a myriad of tools and functions. One such functionality is the handling of floating-point numbers, particularly with the Double and Float wrapper classes. Today, we are going to unravel the mysteries around the Double and Float Value() method in Java. Syntax The Value() function in the Double and Float classes in Java is defined as follows: public double doubleValue() public float floatValue() Explanation of Syntax These techniques are a piece of the Twofold and Float covering classes. The doubleValue() technique changes over the Twofold item into a twofold crude, ... Read More

Count occurrence of a given character in a string using Stream API in Java

Sonal Meenu Singh
Updated on 31-Jul-2023 19:47:33

5K+ Views

Introduction In this tutorial, we will implement an approach that counts how many times a particular character appears in a string using the Stream API in Java. A string is a collection of characters and we will use a String class method to separate string characters. We will take an input string and define a character we want to count. The functions used in this approach are the chars() method of the String class and the filter() method of the Stream interface. char() = It is a String class instance method. It returns the intstream values. The stream contains ... Read More

Print first and last character of each word in a string

Mallika Gupta
Updated on 31-Jul-2023 17:49:26

714 Views

Introduction A C++ string is contiguous storage of alphanumeric characters as well as special characters. A string has the following properties − Every C++ string is associated with a fixed length. Character operations can be easily performed with the string characters. A string is composed of words, which are space separated. In this article, we are going to develop a code that takes as input a string, and displays the last character of each word in the string. Let us look at the following example to understand the topic better − Sample Example Example 1 − str − ... Read More

Pairs of strings which on concatenating contains each character of “string”

Mallika Gupta
Updated on 31-Jul-2023 17:42:45

35 Views

Introduction A stream of characters flowing together collectively comprising of alphanumeric characters as well as special symbols can be termed as a C++ string. String concatenation is an important aspect of the string data structure, since it is used to combine different sub strings or words to form complete sentences. Concatenation in C++ can be simply done using the + operator. In this article, we are going to develop a code that takes as input an array of string, and then analyses each pair to see if that pair contains all the letters of the word “string” . Let us ... Read More

Print last character of each word in a string

Mallika Gupta
Updated on 31-Jul-2023 17:46:19

769 Views

Introduction C++ strings are essentially a combination of words used as a storage unit to contain alphanumeric data. The words in a string are associated with the following properties − The word positions begin with 0. Every word is associated with a different length. The characters combine together to form words, which eventually form sentences. By default, the words are separated by a space character. Every word contains at least one character. In this article, we are going to develop a code that takes as input a string, and displays the last character of each word in ... Read More

Longest double string of a Palindrome

Mallika Gupta
Updated on 31-Jul-2023 17:39:35

58 Views

Introduction A contiguous sequence of characters, comprising of upper case, lower case, repetitive or unique alphanumeric characters form a C++ string. Every string is recognized by a unique length parameter, which may be odd or even in nature. A palindromic string is the same sequence of characters encountered from both the beginning as well as the end. The characters at equivalent positions from start and end do not differ. They may be even length or odd length palindromes. The odd length palindrome has a middle character separating the two equivalent halves. In this article, we are going to develop a ... Read More

Count of strings satisfying the given conditions

Mallika Gupta
Updated on 31-Jul-2023 17:28:44

69 Views

Introduction A string in C++ is also a primitive data type which is comprised of alphanumeric characters. The letters in a string are case sensitive, but strings can contain both upper and lower case. In this article, we are given an input array of lowercase strings, and require the count of the pair of strings from the array satisfying the following conditions − Both the strings should have the same first and last vowel Both the strings have an equal number of pairs An array is a data structure simulating the storage of similar elements. A C++ array ... Read More

Double colon (::) operator in Java

Way2Class
Updated on 31-Jul-2023 17:13:58

2K+ Views

In Java, the twofold colon (::) administrator, otherwise called the strategy reference administrator, is a strong element presented in Java 8. It gives a succinct and rich method for alluding to techniques or constructors without conjuring them. This administrator improves on the code and upgrades code coherence, making it an important instrument for designers. In this article, we will investigate the language structure of the twofold colon administrator, talk about its applications, and give code guides to better comprehension. Syntax The double colon operator consists of two colons (::) sandwiched between the class name or object reference and the method ... Read More

Advertisements