power using recursion

In this article, we are going to find power of given number using recursion in java. Example:- if num=2 and power=3, then the output will be 8. steps:- java code to calculate power using recursion:- Output:- You can use the same approach to calculate the power using recursion in other programming languages like C, C++, … Read more

Swap two numbers

In this article, we are going to swap two numbers by using two different approach. first approach is using third variable and second one is without using third variable. Swapping two numbers using third variable. In this approach, we used a temporary i.e. third variable two swaps two numbers. Here we are going to use … Read more

Distinct elements in array

In this article, we are going to find distinct element in array using java code. Example:- if n=5(size of ann array) arr={45,23,5,23,45}, then the output will be 3. Steps:- Java code to find distinct element in given array:- Output:- You can use same logic to find distinct element in given array using another programing language … Read more

maximum and minimum element in the array

In this article, we are going to find maximum and minimum element in the given array using java code. Example:- if n=4(size of an array) arr={48,58,5,2}, then the output will be 58 is the maximum element and 2 is the minimum element. steps:- Java code to find maximum and minimum element in an array:- Output:- … Read more

minimum element in array

In this article, we are going to find minimum element in array using java code. Example:- If n=4(size of an array) arr={5,8,9,4}, then the output will be 4. Steps:- Java code to print minimum element in array. Output:- You can use the same logic to print minimum element in an array using other programing languages … Read more

maximum element in array

In this article, we are going to find maximum element in array using java code. Example:- If n=4(size of an array) arr={45,8,9,4}, then the output will be 45. Steps:- Java code to print maximum element in array. Output:- You can use the same logic to print maximum element in an array using other programing languages … Read more

check if array is sorted

In this article, we are going to check if the array is sorted using java. Example:- If arr=[1,2,3,4,5], then the output will be yes. because it is sorted. if arr=[2,4,6,10,8], then the output will be no. because it is not sorted. Steps:- Java code to check if array is sorted or not:- Output:- You can … Read more

Sum of all divisors of a number.

In this article, we are going to find the sum of all divisors of a given number. Example:- if number = 6, then the output will be 1+2+3+6=12. Steps:- Java code to find the sum of all divisors of a given number:- Output:- You can use the same logic to find the sum of all … Read more

All divisors of a number

In this article, we are going to find all divisors of a number using java code. Example:- if number=8 ,then the output will be 1,2,4,8. Steps:- Java code to find all divisors of given number:- Output:- We can use the same logic to find all divisors of a given number using other programming languages like … Read more

first digit of a number

In this article, we are going to write code for finding the first digit of a number. Example:- if number = 7122344 then output will be 7. Steps:- Java code to find last digit of a number:- Output:- You can use the same logic to find the first digit of a number using other programming … Read more

login registration using grpc and java

In this article, we are going to create a login registration service using gRPC and Java. If you are completely new to gRPC with Java, then please check this article https://gangforcode.com/grpc-project-using-java/ first because there are some dependencies and plugins required for gRPC and proto files. Database For this project, i used MySQL and created a … Read more

GCD of two numbers using java.

In this article, we are going to find the GCD(Greatest Common Divisor) of two numbers using java code. Example:- if a=10(first number), b=15(second number) then GCD of a and b will be 5. Steps:- Java code to find GCD of two numbers. Output:- You can use the same logic to find the GCD of two … Read more

LCM in java

In this article we going to calculate LCM of two numbers using java code. Example:- if a=10(first number), b=15(Second number) then answer=30, it is the LCM of 10 and 15. Steps:- Java code to find LCM of two numbers. Output:- You can use the same logic to find the LCM of two numbers using other … Read more

Factorial using java

In this article, we are going to print factorial of any number using java code. Example :-if n=5, solution:- 5*4*3*2*1=120 What is factorial? The factorial of any number is equal to the product of all positive numbers less then or equals to that number. Steps:- Java code to print factorial:- Output:- You can use the … Read more

Triangle pattern program using java

In this article, we are going to print java code to print triangle pattern. Example if n=4. Steps:- Take the input for number of lines in a triangle, from the user using scanner. Run a loop for number of lines. Inside the previous loop run another loop for printing * which equals to line’s number. … Read more

Inverted triangle pattern using java

In this article we going to print inverted triangle pattern using java code. Example:- if n=4 (n is the number of lines in triangle.) Steps:- Take input from the user for the height of the triangle using a scanner. Run a loop for all the rows in the triangle. Inside loop run another loop for … Read more