Nancy Den

Nancy Den

178 Articles Published

Articles by Nancy Den

Page 7 of 18

Selects the element with id="tutorials" with CSS

Nancy Den
Nancy Den
Updated on 11-Mar-2026 205 Views

To select all the elements with id=”tutorials”, you can try to run the following code.Use the #id CSS selector to achieve this,Example                    #tutorials {             border: 3px solid red;          }                     Tutorialspoint       Learning       Tutorials on web dev, programming, database, networking, etc.       Every tutorials has lessons with illustrations and figures.    

Read More

C++ Program to Solve the 0-1 Knapsack Problem

Nancy Den
Nancy Den
Updated on 29-Apr-2025 6K+ Views

In the 0-1 knapsack problem, a set of items is given, each with a weight and a value. We need to determine the number of each item to include in a collection so that the total weight is less than or equal to the given limit and the total value is as large as possible.ExampleThe following example explains the 0-1 knapsack problem: Input: Weights: 1 2 3 6 7 4 Values: 10 20 25 40 60 70 Max Weight Capacity: 7 Output: Maximum value: 100 Here is an explanation of the above example: Weights: ...

Read More

C++ Program to Find Fibonacci Numbers using Matrix Exponentiation

Nancy Den
Nancy Den
Updated on 25-Apr-2025 3K+ Views

The Fibonacci numbers, commonly denoted as F(n) forms a sequence, called the Fibonacci sequence. In Fibonacci series, each number is the sum of the two previous two numbers, starting from 0 and 1. It is represented as F(n) = F(n-1) + F(n-2). The matrix exponentiation method is used to calculate the powers of matrix efficiently with better time complexity. In this article, we provide a value of n. This n is the value up to which we want to find the Fibonacci numbers using the matrix exponentiation method in C++. Here is an example of the Fibonacci series up to ...

Read More

C++ Program to Find Fibonacci Numbers using Dynamic Programming

Nancy Den
Nancy Den
Updated on 21-Feb-2025 5K+ Views

In this article, we will learn how to calculate Fibonacci numbers efficiently using dynamic programming in C++. The Fibonacci sequence starts with 0 and 1, and each next number is the sum of the two preceding ones. The basic recursive method works but becomes very slow for larger numbers because it repeats the same calculations many times. Dynamic programming solves this by storing the results of previous calculations, which makes the process much faster and more efficient. For example, if we want to find the 6th Fibonacci number, the sequence will look like this: F(0) = 0 ...

Read More

Java Program to fill elements in a float array

Nancy Den
Nancy Den
Updated on 10-Feb-2025 461 Views

In this article, we will learn how to fill elements in a float array in Java. The Arrays.fill() method is used to assign a specified value to each element of the array. Array fill() method The Arrays.fill() method in Java sets all elements of an array to a given value, making it useful for quickly initializing or resetting arrays. The Arrays.fill() method works with various data types like int, char, double, and boolean. It makes it easy to fill arrays with a default or specific value. Syntax Arrays.fill(array, value)Arrays.fill(array, start, end, value) ...

Read More

Java program to add period to LocalDate

Nancy Den
Nancy Den
Updated on 08-Nov-2024 772 Views

In this program, we will learn to add a specific period to a date using Java’s LocalDate class. By using Java's Period class, we can specify an amount of time (such as months and days) and then add this period to a LocalDate. The program demonstrates how to set a period and apply it to a given date to get a new, updated date. Steps to add Period to LocalDate  Following are the steps to add Period to LocalDate − Import LocalDate and Period from java.time package to work with dates and periods. ...

Read More

Java program to get the prime numbers with BigInteger type

Nancy Den
Nancy Den
Updated on 04-Nov-2024 707 Views

In this article, we will learn how to generate prime numbers using the BigInteger class in Java. A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. Here, we have the BigInteger type, which has operations for modular arithmetic, GCD calculation, primality testing, prime generation, etc. Steps to get the prime numbers with BigInteger type Following are the steps to get the prime numbers with BigInteger type − First, we will import the BigInteger from the java.math package. ...

Read More

Java program to generate random number with restrictions

Nancy Den
Nancy Den
Updated on 15-Oct-2024 1K+ Views

In this article, we will learn to generate random numbers with restrictions in Java. We will be using the Java Random class from java.util package. Random class Random class is imported from java.util package. The instance of this class is used to generate the random numbers and provides different numbers of different types integer, double, long, float, etc. Steps to generate random numbers with restrictions Following are the steps to generate random numbers with restrictions − Import the Random class from the java.util package. Initialize the Random object to generate random values. ...

Read More

Java program to check if none of the string in the list matches the condition

Nancy Den
Nancy Den
Updated on 29-Sep-2024 947 Views

In this article, you will learn how to check if none of the strings in a list start with a specific letter using Java. This approach is useful for validating or filtering data. We will use the Stream API to evaluate the condition and return a boolean result based on whether any string starts with the given letter. Problem Statement Write a program in Java to check if none of the strings in the list matches the condition. Input pqr, stu, vwx, yza, vwxy Output No match for the starting letter as f? = true Steps to check if none of ...

Read More

How to draw a star by using canvas HTML5?

Nancy Den
Nancy Den
Updated on 16-Dec-2021 10K+ Views

Drawing on the HTML canvas is to be done with JavaScript. Use the HTML DOM Method getElementById() and getContext() before drawing on the canvas. To draw a star in HTML, use the canvas element.With canvas, use the lineTo() method to draw a star. The lineTo() method includes x and y parameter values, which positions the lines to help you in drawing.To draw canvas on HTML document:ExampleYou can try to run the following code to draw a star using HTML5 canvas           HTML5 Canvas Tag                   ...

Read More
Showing 61–70 of 178 articles
« Prev 1 5 6 7 8 9 18 Next »
Advertisements