Check If Two of Three Boolean Variables Are True in Java

Manisha Chand
Updated on 05-Jun-2025 10:51:50

472 Views

In this article, we will learn to check if any two out of three boolean values are true or not. Boolean variables are datatypes that contain only true or false values. Below is a demonstration of the same - Input: true, true, falseOutput : Two of the three variables are true Checking if two of three Boolean variables are trueIn this article, we will discuss two approaches to check it, and they are - Using if-else Condition ... Read More

Calculate Compound Interest in Java

Manisha Chand
Updated on 05-Jun-2025 10:48:07

16K+ Views

In this article, we will understand how to calculate compound interest in Java. Compound interest is calculated using the following formula. Amount = P(1 + R/100)t Compound Interest = Amount - Principle where, P is the principal amount T is the time R is the rate Compound interest is the interest calculated on the initial principal and also on the accumulated interest of previous periods. In other words, Compound Interest = Interest on Principal + Interest on Interest. We'll learn how to get user input for the principal amount, interest rate, and time period, and then calculate the compound interest based ... Read More

Find Even Sum of Fibonacci Series Till Number N

Manisha Chand
Updated on 05-Jun-2025 10:22:18

3K+ Views

In this article, we will learn how to find the even sum of the Fibonacci series up to a given number N. A Fibonacci series is a series where the next term is the sum of the previous two terms. An even Fibonacci series is a group of all the even numbers in the Fibonacci series. The first two terms of the Fibonacci sequence are 0 and 1. Fn = Fn-1 + Fn-2 Hence, a Fibonacci series can look like this - F8 = 0 1 1 2 3 5 8 13 or, this F8 = 1 1 2 3 5 ... Read More

Decimal Type in C#

Samual Sam
Updated on 05-Jun-2025 09:58:40

2K+ Views

The decimal type is a value type and has the plus, minus, multiply and divide operators. Firstly, set two decimal values − decimal d1 = 5.8M; decimal d2 = 3.2M; To add decimals − d1 = d1 + d2; Let us see an example to add two decimal values − Example Live Demo using System; using System.Linq; class Demo { static void Main() { decimal d1 = 5.8M; decimal d2 = 3.2M; d1 = d1 + d2; Console.WriteLine(d1); } } Output 9.0

Display All Prime Numbers from 1 to N in Java

Manisha Chand
Updated on 05-Jun-2025 09:55:00

37K+ Views

In this article, we will understand how to display all the prime numbers from 1 to N in Java. All possible positive numbers from 1 to infinity are called natural numbers. A number is a prime number if its only factors are 1 and itself and cannot be divided by any other number. 11 is a prime number. Its factors are 1 and 11 itself. Some examples of prime numbers are 2, 3, 5, 7, 11, 13, and so on. 2 is the only even prime number. All other prime numbers are odd numbers. Below is a demonstration of the ... Read More

Convert std::string to LPCWSTR in C++

Aman Kumar
Updated on 04-Jun-2025 18:53:51

3K+ Views

std::string The std::string is a class of C++ Standard Library (STL) that represents a string (sequence of characters). It is used to handle strings with better memory management, i.e., it provides dynamic memory management for strings and supports a rich set of in-built functions for string manipulation. Syntax Following is the syntax of string: string str = "tutorialspoint"; std::LPCWSTR The LPCWSTR stands for Long Pointer to Constant Wide STRing. It is a constant string of 16-bit Unicode characters, which may be null-terminated. It is the same as a string but with wide characters. Syntax Following is the syntax of ... Read More

Find Length of a String Without string.h and Loop in C

Aman Kumar
Updated on 04-Jun-2025 18:53:35

654 Views

C provides libraries for string operations such as the string.h header file that contains a strlen() function, which counts the length of a string. Otherwise, a loop can be used to count the string length. There are also different ways to find the length of a string apart from the above two methods. So, basically, in this article, we will learn how to find the length of a string without string.h and loop in C. Find Length of a String Without string.h and Loop in C There are the following ways to find the string's length without using the string.h ... Read More

Insertion and Deletion in STL Set in C++

Farhan Muhamed
Updated on 04-Jun-2025 18:48:48

1K+ Views

The STL set is a container that stores unique elements in a sorted order. Insertions and deletions are common operations performed in containers like std::set and std::vector. In this article, we will learn how to insert and delete elements in a C++ STL set. Insertion in STL Set To insert a new element into a std::set you can use the insert method or the emplace method. Let's understand how to use these methods with examples. Using insert Method Using emplace Method 1. Using insert Method The insert ... Read More

Convert std::string to Lower Case in C++

Farhan Muhamed
Updated on 04-Jun-2025 18:48:16

9K+ Views

The STL library in C++ provides various inbuilt functions and methods to manipulate strings, such as converting them to lower case or upper case. In this article, we will learn all the approaches to convert a std::string to lower case in C++. First of all, let's understand the problem statement. In this problem, you are given a string as input and you need to convert it to lower case. The string may contain any type of characters such as letters, digits, and special characters. For example: // Input String std::string str = "Hello World! 123 @ TutorialsPoint"; // ... Read More

Find Peak Element of an Array Using Binary Search in C++

Ravi Ranjan
Updated on 04-Jun-2025 18:42:56

990 Views

The peak element in an array is an element that is greater than its neighbor elements i.e., its left and right element. If the peak element is the starting element, then it should be greater than the next element (second element). If the peak element is the last element, then it should be greater than its previous value i.e., the second last element. In this article, we have an array of integers. Our task is to use the binary search algorithm to find the peak element present in the given array. Example Here are two examples to understand the ... Read More

Advertisements