Point of Intersection of Two Lines in C++

Sunidhi Bansal
Updated on 02-Dec-2024 00:24:08

4K+ Views

Given points A and B corresponding to line AB and points P and Q corresponding to line PQ; the task is to find the point of intersection between these two lines. Note − The points are given in 2D plane on X and Y coordinates. Here A(a1, a2), B(b1, b2) and C(c1, c2), D(d1, d2) are the coordinates which are forming two distinct lines and P(p1, p2) is the point of intersection. (just for a diagrammatic explanation of the point of intersection) How to find the point of intersection − Let’s take the above figure as − Example So ... Read More

Count Objects Using Static Member Function in C++

Sunidhi Bansal
Updated on 02-Dec-2024 00:23:52

2K+ Views

The goal here is to count the number of objects of a class that are being created using a static member function. A static data member is shared by all objects of the class commonly. If no value is given, a static data member is always initialized with 0. A static member function can only use static data members of that class. We are using a class Student here. We will declare a static data member count which will store the count of objects. A static member function rollCall(void) will display the count of objects as roll no.s of students ... Read More

Use Enums in C++

karthikeya Boyini
Updated on 02-Dec-2024 00:23:27

10K+ Views

Enumeration is a user defined datatype in C/C++ language. It is used to assign names to the integral constants which makes a program easy to read and maintain. The keyword “enum” is used to declare an enumeration. The following is the syntax of enums. Syntax enum enum_name{const1, const2, ....... }; Here, enum_name − Any name given by user. const1, const2 − These are values of type flag. The enum keyword is also used to define the variables of enum type. There are two ways to define the variables of enum type as follows. enum colors{red, black}; enum suit{heart, diamond=8, ... Read More

Compare Two Strings Lexicographically in C++

Arnab Chakraborty
Updated on 02-Dec-2024 00:22:48

10K+ Views

Lexicographic string comparison states the strings are compared in dictionary order. For example, if two strings ‘apple’ and ‘appeal’ are there, the first string will come next because the first three characters ‘app’ are the same. Then for the first string, the character is ‘l’ and in the second string, the 4th character is ‘e’. Since ‘e’ is shorter than ‘l’, it will come first if we arrange them in lexicographic order. Before arranging, the strings are compared lexicographically. In this article, we will see different techniques to compare two strings in a lexicographic manner using C++. Using compare() functions ... Read More

Filter JavaScript Array by Multiple Strings

AmitDiwan
Updated on 29-Nov-2024 19:11:57

1K+ Views

Filtering an array by multiple strings in JavaScript involves identifying elements that match any string from a given list. This is commonly used in search filters, dynamic matching, or data processing tasks. JavaScript provides simple tools like the filter method and techniques such as includes for exact matches or regular expressions for pattern-based matching. These approaches help efficiently narrow down arrays based on specific criteria. Approaches to filter array by multiple strings Here are the following approaches to filter an array by multiple strings in JavaScript using regex (case-sensitive) and filter with includes: Using Regular Expressions ... Read More

Convert LocalDateTime to java.util.Date

karthikeya Boyini
Updated on 29-Nov-2024 19:11:15

2K+ Views

In this article, we will learn how to convert a LocalDateTime object to a java.util.Date object in Java. The conversion is essential when working with modern and legacy date/time APIs, ensuring compatibility between them. LocalDateTime Class The java.time.LocalDateTime class represents a specific date and time without including any time-zone details, following the ISO-8601 calendar system. For instance, it can represent values like 2007-12-03T10:15:30. This makes it ideal for scenarios where time-zone information is not required, focusing solely on the local date and time. Java Date class The java.util.Date class represents a specific moment in time, accurate to the ... Read More

Create Submit and Clear Buttons for Form Submission in JavaScript

AmitDiwan
Updated on 29-Nov-2024 19:08:48

1K+ Views

Form handling is a fundamental aspect of web development. A Submit button sends the form data for processing, while a Clear button allows users to reset or empty the form inputs. This functionality enhances user experience and ensures proper data entry.In this tutorial, we'll learn how to create a form with a Submit button for handling submissions and a Clear button for resetting inputs using JavaScript. We'll also handle the actions triggered by these buttons effectively. Creating a submit button for form submission Below is an example of creating a submit button for form submission and another button to ... Read More

C# Program to Calculate Compound Interest

AYUSH MISHRA
Updated on 29-Nov-2024 17:58:55

4K+ Views

Compound interest is interest where the interest is calculated by adding the interest that has already been calculated in a previous time period. In this article, we are going to discuss how we can calculate compound interest using C#. What is Compound Interest? Compound Interest is the interest that calculates interest on the initial principal and also includes the interest of the previous period. In compound interest, the previous interest is included in the current interest, causing the interest to grow in an exponential manner. Example Input: principal = 20, 000, rate = ... Read More

JavaScript Program to Find Simple Interest

AmitDiwan
Updated on 29-Nov-2024 15:09:38

9K+ Views

To find simple interest in javascript, we will find the product of principal amount, rate of interest(%) and time period. Simple intrest is a quick and easy method to find the intrest charge or extra amount paid by borrower to lender on certain amount of principal within a time period. In this article we are given a data of principal, rate and time, our task is to write a JavaScript program to find simple interest. Users must be familiar with the formula to calculate the simple interest, arithemetic operators in javascript and javascript functions. Formula: Simple ... Read More

Clear Complete Cache Data in ReactJS

Farhan Muhamed
Updated on 29-Nov-2024 12:11:40

776 Views

Caching is a technique used to store reusable resources in the user's browser. Caches are of different types, for example, Local Storage Cache, Session Storage Cache, and Service Worker Cache, each of these has a different approach to clearing completely from browser. In this article, we will explain how to clear all caches in a React app. What is Cache? Caches are temporarily stored resources on a web page such as variables, user preferences, images, style sheets, scripts, etc. These are used to reduce server load and speed up page load times by reusing previously fetched resources. Following ... Read More

Advertisements