Programming Articles

Page 115 of 2544

Parsing a comma-delimited std::string in C++

Farhan Muhamed
Farhan Muhamed
Updated on 23-Apr-2025 9K+ Views

In this article, we will discuss all the approaches to parse a string delimited by comma using a C/C++ program. First of all, let's understand the problem statement. The input of this problem is a string containing multiple words that are seperated by commas. Our task is to print each word space seperated to the output console. For example: // Input String "Hello, World, From, 2025" // Output "Hello" "World" "From" "2025" Parse Comma Delimited String Here is the list of approaches to parse comma delimited string to words using c++ program, which we ...

Read More

How do we assign values to variables in a list using a loop in Python?

Pranav Indukuri
Pranav Indukuri
Updated on 23-Apr-2025 7K+ Views

In Python, lists are a useful way to store multiple elements in a single variable. To assign values to each entry in a list, loops are often needed. This strategy simplifies the process and improves the clarity of your code. This chapter will look at how to assign values to variables in a list using different loop types, using basic examples. Using Simple Loop Iterations In this method, we use the for loop to append elements to the lists. When we do not enter any element into the list and stop appending, then we just press the Enter key. To ...

Read More

How to match at the beginning of string in python using Regular Expression?

Pranav Indukuri
Pranav Indukuri
Updated on 23-Apr-2025 13K+ Views

A regular expression in Python is a group of characters that allows you to use a search pattern to find a string or set of strings. RegEx is a term for regular expressions. To work with regular expressions in Python, use the re package. Understanding String Matching in Python String matching is a basic Python method that allows you to look for and find patterns in a given text. The match() function, a component of the re (regular expression) package, is one of the widely used methods for this purpose. Use the match() method to determine whether the beginning of ...

Read More

How can import python module in IDE environment available in tutorialspoint?

Malhar Lathkar
Malhar Lathkar
Updated on 23-Apr-2025 1K+ Views

The Tutorialspoint coding environment normally helps you to run Python code directly in your browser, but the capacity to import external modules can be limited. Importing Python Module So you can use Python's built-in libraries and modules. To load a module into the Python IDE environment on tutorialspoint, follow the steps below - Step 1: First of all, you need to open the Tutorialspoint Python IDE. So, go to the Tutorialspoint Python IDE. ...

Read More

Is Swing thread-safe in Java?

Alshifa Hasnain
Alshifa Hasnain
Updated on 23-Apr-2025 2K+ Views

No, Java Swing components are not thread-safe in Java. This means that whenever Swing components should be accessed or changed, it is done mostly by using a single thread, the EDT. Why Swing Components are not thread-safe One of the main reasons Java Swing is not thread-safe is to simplify the task of extending its components. Another reason for that Java Swing is not thread-safe due to the overhead involved in obtaining and releasing locks and restoring the state. Below are some methods given by Swing for safe operation with its UI: SwingUtilities.invokeLater(): In ...

Read More

C++ Program to Implement Euler Theorem

Ravi Ranjan
Ravi Ranjan
Updated on 23-Apr-2025 798 Views

Euler's theorem states that if two numbers (a and n), are co-prime i.e. gcd(a, n)=1, then 'a' raised to the power of Euler's totient function of n (a^φ(n)) is congruent to 1 modulo n i.e. a^φ(n) ≡ 1 (mod n). The Euler's Totient Function is denoted as φ(n) and represents the count of integers from 1 to n that are relatively co-prime to n. In this article, we have two co-prime integers. Our task is to implement the Euler Theorem in C++ using given co-prime numbers. Here is an example to verify the Euler Theorem for two co-prime numbers: ...

Read More

C++ Program to Implement Fermat’s Little Theorem

Ravi Ranjan
Ravi Ranjan
Updated on 23-Apr-2025 1K+ Views

Fermat's Little Theorem states that if p is a prime number and a is an integer not divisible by p, then a^(p-1) is congruent to 1 modulo p. It can be represented as a(p-1) ≡ 1 (mod p). It can also be said that if any integer a is raised to the (p-1) where p is a prime and gcd(a, p) =1, then a^(p-1)-1 is divisible by p. In this article, we have two integers i.e. 'a' and a prime number 'p' such that a is not divisible by p. Our task is to implement Fermat's Little theorem using these ...

Read More

C++ Program to Implement Park-Miller Random Number Generation Algorithm

Ravi Ranjan
Ravi Ranjan
Updated on 23-Apr-2025 696 Views

The Park-Miller algorithm is a type of linear congruential generator (LCG) that is used to generate pseudo-random numbers. It is also called the minimal standard random number generator. The general formula of a random number generator (RNG) of this type is: X_{k+1} = g X(k) mod n where the modulus n is a prime number or a power of a prime number, the multiplier g is an element of high multiplicative order modulo n, and the seed X0 is co-prime to n. In this article, we will be using Park-Miller algorithm to generate 5 pseudo-random numbers using C++. Here is ...

Read More

How to match at the end of string in python using Regular Expression?\\n\\n

Pranav Indukuri
Pranav Indukuri
Updated on 23-Apr-2025 15K+ Views

A regular expression in Python is a set of characters that allows you to use a search pattern to find a string or a group of strings. These are used within Python using the re package. To match the end of the string in Python by using a regular expression, we use the following regular expression -^/w+$ Here, $ implies the start with. /w returns a match where ...

Read More

How to match any non-digit character in Python using Regular Expression?\\n\\n

Pranav Indukuri
Pranav Indukuri
Updated on 23-Apr-2025 7K+ Views

A regular expression is a group of characters that allows you to use a search pattern to find a string or a set of strings. RegEx is another name for regular expressions. The re module in Python is used to work with regular expressions. In this article, we learn how to extract non-digit characters in Python using regular expressions. We use \D+ regular expression in Python to get non-digit characters from a string. Where, \D returns a match that does not contain digits. + implies zero or more occurrences of characters. ...

Read More
Showing 1141–1150 of 25,433 articles
« Prev 1 113 114 115 116 117 2544 Next »
Advertisements