Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2752 of 3366
4K+ Views
Decimal numbers are the set of numbers with base 10, whereas binary numbers are the numbers with base 2. In this article, we will learn how to convert a decimal number to a binary number using stack data structure in C++ program. First of all, let's understand how decimal to binary conversion technique works. Decimal to Binary Conversion Technique To convert a decimal number to a binary number follow the steps below: Divide the decimal number by 2 Save the reminder (either 1 or 0) in a place. ... Read More
10K+ Views
In this article, we will learn how to check for a balanced parentheses using stack data structure in C++ program. First of all let's understand what is balanced parentheses. A string of parentheses is said to be balanced parentheses, If Every opening bracket has corresponding closing bracket of same type. The brackets are closed in correct order. For an example, we can say that the expression [{} () {()}] it is balanced. But {[}] is not balanced eventhough it contains opening and closing brackets of same type. ... Read More
2K+ Views
Here we will see how to replace substring with another substring. It replaces the portion of the string that begins at character pos and spans len characters.The structure of the replace function is like below:string& replace (size_t pos, size_t len, const string& str, size_t subpos, size_t sublen);The parameters are pos: It is an insertion point, str : It is a string object, len : It contains information about number of characters to erase.AlgorithmStep 1: Get the main string, and the string which will be replaced. And the match string Step 2: While the match string is present in the main string: Step 2.1: Replace it with the given ... Read More
6K+ Views
In this article, we will learn the different approaches to replace a part of a string with another string using a C/C++ program. The problem statement of this program is explained below: The input of this problem will be three strings. The task is to replace all the occurrence of the second string with the third string inside the first string. For example: // Input strings "C++ Course is free on Tutorialspoint" "C++" "Python" // Output String "Python Course is free on Tutorialspoint" Replace a Substring With Another String Here is the list of all ... Read More
4K+ Views
Trailing zeros are the zero occuring at the end of a string. In this article, we will discuss different approaches to remove trailing zeros from a string. The below section explains the problem statement. The input of this problem is a non-empty string containing characters and numbers. Our task is to remove all the zero's appering after the last non-zero character in the string. For example: // Input string "012424000" // Output String "012424" Remove Trailing Zeros From String Here is the list of approaches to remove all the trailing zeros from a string ... Read More
17K+ Views
In this article, we will learn all the different approaches to remove the whitespaces from a standard string in C/C++. First of all, let's understand our problem statement. The input of this problem is a non-empty string containing multiple characters and whitespaces between those characters. Our task is to print the string by ignoring all the whitespaces into the output console. For example: // Input String "This is a string" // Output String "Thisisastring" Remove Whitespaces from a String in C++ Here is the list of approaches to remove all the whitespaces from a string using ... Read More
594 Views
Sometimes, in C++ when you try to print a string that containing special characters like escape sequences (), backslashes (\), or quotes(""), the output may not be as expected. To avoid this, C++ provides a feature called raw string literal. In this article, we will discuss what is raw string literal and how to use it in C++. What is Raw String Literal? A raw string literal in C++ is a type of string that preserves the formatting of the string content without changing any escape sequences such as "", "\t", or "". This is useful when you want ... Read More
1K+ Views
The mapToInt() method returns an IntStream consisting of the results of applying the given function to the elements of this stream.The syntax is as followsmapToInt(LongToIntFunction mapper)Here, the parameter mapper is the stateless function applied to each element.Declare LongStream and add some elementsLongStream longStream = LongStream.of(1000L, 13000L, 18000L);Now, use the IntStream and mapToInt()IntStream intStream = longStream.mapToInt(val -> (int) val);The following is an example to implement LongStream mapToInt() in JavaExample Live Demoimport java.util.*; import java.util.stream.IntStream; import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.of(1000L, 13000L, 18000L); IntStream intStream = ... Read More
436 Views
The AbstractSequentialList class provides an implementation of the List interface. For an unmodifiable list, implement the list iterator's hasNext, next, hasPrevious, previous and index methods. For a modifiable list the programmer should implement the list iterator's set method.The syntax is as followspublic abstract class AbstractSequentialList extends AbstractListTo work with the AbstractSequentialList class in Java, you need to import the following packageimport java.util.AbstractSequentialList;First, create an AbstractSequentialList classAbstractSequentialList absSequential = new LinkedList();Now, add elementsabsSequential.add("Accessories"); absSequential.add("Home Decor"); absSequential.add("Books"); bsSequential.add("Stationery");Let us see an example to implement the AbstractSequentialList class in JavaExample Live Demoimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] ... Read More
