Prime numbers are natural numbers greater than 1 with only two factors: 1 and themselves. Examples include 2, 3, 5, 7, etc. The smallest prime number is 2. Problem Description We are given an array and need to find the number of prime numbers in the array using C#. Below is an example to understand the problem: Examples Input: array = { 3, 6, 12, 7, 9, 11} Output: array = {3, 7, 11} Explanation: The numbers 3, 7, and 11 have only two factors: 1 and themselves, so they are prime numbers. Input: array = {4, ... Read More
Many modern web apps require different themes, like light and dark modes, to enhance a user's experience. However, setting up and changing themes with Tailwind CSS can be confusing for developers. This article offers easy and effective methods to create and manage multiple themes with Tailwind CSS. Approaches to Create Multiple Themes Extending Tailwind Configuration for Themes Using CSS Variables Extending Tailwind Configuration for Themes You can make different themes in Tailwind CSS by changing the Tailwind configuration file (tailwind.config.js). This lets you set up your own ... Read More
React is a well-known JavaScript library mostly used to build dynamic and interactive user interface applications for the web. It is a creation of Facebook, which lets developers create reusable UI components and also provides a virtual DOM on which rendering is to be done. React Native is a new concept that applies the logic of React to developing mobile applications. That means developers can write mobile apps for both iOS and Android operating systems. Using React Native, one would get identical compiling with a single codebase. Using native components instead of elements from the web gives a real ... Read More
An array of characters is called a string. Declaration Following is the declaration declaring an array is as follows − char stringname [size]; For example: char string[50]; string of length 50 characters Initialization Using single character constant − char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’} Using string constants − char string[10] = "Hello":; Accessing − There is a control string "%s" used for accessing the string till it encounters ‘\0’. Finding maximum occurrence The logic to find the maximum occurrence of character is − ... Read More
In JavaScript, the 2D matrix manipulation involves working with arrays of arrays, often to perform operations on rows or columns. In this example, we focus on finding the maximum value in each row of a matrix. Two methods are demonstrated: using nested loops for step-by-step iteration, and using map() with Math.max() for a more concise, functional approach. Both methods return an array of the maximum values from each row, but the map() approach is more efficient and modern. Different approaches Following are the different approaches to finding maximum element of each row in a matrix − ... Read More
If you’re working with arrays in JavaScript, you may encounter situations where your array contains undefined values. This can happen when you're processing data from various sources or working with incomplete datasets. One common problem developers face is summing the values of an array with undefined elements. JavaScript’s reduce() method is a versatile tool that can help you solve this problem efficiently. In this article, we will explore how to use the reduce() method to sum an array, even when it includes undefined values, and ensure that the final result is correct. What is the reduce() Method in JavaScript? The ... Read More
In JavaScript, redirecting a user from one URL to another is a straightforward task. There are multiple ways to achieve this, but we’ll focus on two of the most common and effective methods: window.location.href and window.location.replace(). Both are widely used for different purposes, and understanding when to use each one can help improve user navigation on your site. Approaches to Redirect a URL in JavaScript Following are the different approaches to redirect a URL: Using window.location.href Using window.location.replace() Redirect a URL Using window.location.href Property The window.location.href property is one of ... Read More
To find closest number in array using Javascript, we will be understanding and discussing three different approaches. We will also compare time and space complkexities of all the appproaches used. In this article we are having an array and a target value, our task is to find closest number to target value in array using Javascript. User must know about JavaScript arrays, searching alogorithms such as linear and binary search, sorting, loops, and conditional statement. Approaches to Find Closest Number in Array Here is a list of approaches to find closest number in array in JavaScript which we will ... Read More
Here we will see five different ways to get the string lengths in C++. In C++ we can use the traditional character array string, and C++ also has String class. In different area there are different methods of calculating the string lengths. The C++ String class has length() and size() function. These can be used to get the length of a string type object. To get the length of the traditional C like strings, we can use the strlen() function. That is present under the cstring header file. Another two approaches are straight forward. One by using the while loop, ... Read More
Here in this program we will see how to iterate through each characters of a string in C++. To loop on each character, we can use loops starting from 0 to (string length – 1). For accessing the character we can either use subscript operator "[ ]" or at() function of string object. Input: A string "Hello World" Output: "Hello World" Algorithm Step 1: Get the string Step 2: Use R before string to make it raw string Step 3: End Example Code #include using namespace std; int main() { string my_str = "Hello World"; for(int i = 0; i
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP