Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles on Trending Technologies
Technical articles with clear explanations and examples
Finding Quadrant of a Coordinate with respect to a Circle in C++
We have one circle (center coordinate and radius), we have to find the quadrant of another given point (x, y) lies with respect to the center of the circle, if this is present in the circle, print quadrant, otherwise print error as the point is present outside.Suppose the center of the circle is (h, k), the coordinate of the point is (x, y). We know that the equation of the circle is β(π₯ββ)2+(π¦βπ)2+π2=0Now there are few conditions, based on which we can decide the result.ππ (π₯ββ)2+(π¦βπ)2> π, π‘βππ π‘βπ πππππ‘ ππ ππ’π‘π πππ π‘βπ ππππππππ (π₯ββ)2+(π¦βπ)2= 0, π‘βππ π‘βπ πππππ‘ ππ ...
Read MoreHow to get Exception log from a console and write it to external file in java?
There are several logging frame works available to log your data in to files. You can also define your own method.Example β Using I/O packageFollowing Java program has an array storing 5 integer values, we are letting the user to choose two elements from the array (indices of the elements) and performing division between them. We are wrapping this code in try block with three catch blocks catching ArithmeticException, InputMismatchException and, ArrayIndexOutOfBoundsException. In each of them we are invoking the writeToFile() method.This method accepts an exception object, and appends it to a file using the write() method of the Files ...
Read MoreHTML DOM Input URL type Property
The HTML DOM Input URL type property returns/sets type of Input URL.SyntaxFollowing is the syntax βReturning string valueinputURLObject.typeSetting type to string valueinputURLObject.type = stringValueString ValuesHere, βstringValueβ can be the following βstringValueDetailsemailIt defines that input type is emailurlIt defines that input type is urlradioIt defines that input type is radiotelIt defines that input type is tel and a number keypad is shown for inputExampleLet us see an example for Input URL typeΒ property β Input URL type Β Β form { Β Β Β width:70%; Β Β Β margin: 0 auto; Β Β Β text-align: center; Β Β } Β Β * ...
Read MoreCan we to override a catch block in java?
DescriptionWhen a piece of code in particular method throws an exception, and is handled using try-catch pair. If we are calling this method from another one and, the calling line is wrapped within try-catch pair. Now, how can I override the catch block by the catch block of the calling method.When a piece of code in a method throws an exception (compile time) we must either handle it by wrapping it within the try-catch pair or, throw it (postpone) to the calling method using the throws keyword else a compile time error occurs.In the following Java example the code in ...
Read MoreAn interesting method to print reverse of a linked list in C++
A linked list is a data structure that stores data elements in linked form. Each node of the linked list has a data element and a link.Print reverse of a linked list is a common problem that needs to be addressed in problem solving. So, here we will learn an interesting way to print reverse of a linked list in c++ programming language.Generally print a reverse linked list needs modifications in the list or multiple traversing of the list but this method does not require any such things and also traverses the linked list only once.The logic of this method ...
Read MoreCan we throw an Unchecked Exception from a static block in java?
A static block is a block of code with a static keyword. In general, these are used to initialize the static members. JVM executes static blocks before the main method at the time of class loading.Examplepublic class MyClass { Β Β static{ Β Β Β System.out.println("Hello this is a static block"); Β Β } Β Β public static void main(String args[]){ Β Β Β System.out.println("This is main method"); Β Β } }OutputHello this is a static block This is main methodExceptions in static blockJust like any other method in Java when an exception occurs in static block you can handle it using try-catch pair.Exampleimport ...
Read MoreC++ program to find two numbers with sum and product both same as N
In this tutorial, we will be discussing a program to find two numbers (say βaβ and βbβ) such that botha+b = N and a*b = N are satisfied.Eliminating βaβ from both the equations, we get a quadratic equation in βbβ and βNβ i.eb2 - bN + N = 0This equation will have two roots which will give us the value of both βaβ and βbβ. Using the determinant method to find the roots, we get the value of βaβ and βbβ as, $a= (N-\sqrt{N*N-4N)}/2\ b= (N+\sqrt{N*N-4N)}/2 $Example#include //header file for the square root function #include using namespace std; ...
Read MoreCheck horizontal and vertical symmetry in binary matrix in C++
Suppose we have a binary matrix of order M x N. The task is to check whether the matrix is horizontally symmetric, vertically symmetric or both. One matrix is said to be horizontally symmetric if the ith row is the same as the (M β i)th row, this is said to be vertically symmetric if the jth column is the same as the (N β j)th column. Suppose the input matrices are like below β011101011This is Horizontally symmetric.111101111This is Vertically symmetric.111101111This is Horizontally as well as vertically symmetric.We will solve this problem using two phases. At first, we will check ...
Read MoreC++ program to find uncommon characters in two given strings
In this article, we will be discussing a program to find out the uncommon characters during comparison of two different given strings.As we know, strings are nothing but an array of characters. Therefore, for comparison we would be traversing through the characters of one string and simultaneously checking if that element exists in the other string.If we let the first string be A and the second string B.Then it would give us A - B. Similarly we can calculate B - A.Combining both of these results we would get( A - B ) βͺ ( B - A )i.e the ...
Read MoreC++ program to find union and intersection of two unsorted arrays
In this article, we will be discussing a program to find the union and intersection of two given unsorted arrays.Let us denote the two arrays with βAβ and βBβ. Then union of those arrays is denoted by A βͺ B which is basically an array of all the elements in both the given arrays; provided that each element repeats only once.To find this, we will create a separate array and copy down all the elements from the first array. Then we will traverse through the elements of the second array and check if it is already present in the union ...
Read More