## GCD of Two Numbers in Java Using While

by Dinesh Thakur Category: Control Structures

Algorithm for GCD of Two Numbers :

step 2: Repeat through step-5 while a not equals to 0

step 3: Set gcd=a

step 4: a=b%a

step 5:b=gcd

step 6: Print gcd

step 7: Exit

## Swap Variables in a Different Way Without Using Third Variables

by Dinesh Thakur Category: Control Structures

Algorithm for Swap Variables in a Different Way:

step 2: a=(a+b)-(b=a)

step 3: Print a,b

step 4: Exit

## Swap Two Variables Using XOR Operator Using Java Example

by Dinesh Thakur Category: Control Structures

Algorithm for Swap Two Variables Using XOR Operator:

step 2: a=a^b

step 3: b=b^a

step 4: a=a^b

step 5: Print a,b

step 6: Exit

## Strong Number Program in Java Example

by Dinesh Thakur Category: Control Structures

If sum of factorial of each digit of the number is same as the actual number then that number is called as strong number.

## Armstrong Number With in Range Java Example

by Dinesh Thakur Category: Control Structures

Algorithm for Armstrong Number with in Range:

step 2: Set count=0, b= 1

step 3: Repeat through step-11 while b less than or equals to range

step 4: Set sum=0

step 5: Set c=b

step 6: Repeat through step-9 while c greater than 0

## Armstrong Number in Java Example

by Dinesh Thakur Category: Control Structures

Algorithm for Armstrong Number:

step 1:Set s=0

step 3: Set b=num

step 4: Repeat through step-7 while num greater than 0

step 5: r=num%10

step 6: s=s+(r*r*r)

## Prime Numbers Between Range Java Example

by Dinesh Thakur Category: Control Structures

Algorithm For Prime Numbers between Range:

step 1: Set num=1

step 3: Repeat through step-9 while num less than or equals to range

step 4: Initialize b= 1, c=0

## Prime Number Program in Java Using Scanner Example.

by Dinesh Thakur Category: Control Structures

Suppose, the value entered is say 121. It is assigned to an integer variable num. Now, num is divided by all the numbers from 2 to 8 (because a number can be divided by 1 and itself) (% rehrrns remainder). If the number is divided by any number from 2 to 8, its remainder will come to be 0 and in that case the message "Number is not prime" is displayed on the screen. 121 is not divisible by 2 but is no doubt divisible by 3 which returns remainder as 0 and hence it is not a prime number.

## Perfect Number Program in Java Example.

by Dinesh Thakur Category: Control Structures

A Perfect Number is sum of its positive divisors, excluding the number itself. The First Perfect number is 6, For example 6 is a perfect number as 1,2 and3 are its divisors and the sum of divisors= ( 1 + 2 + 3)  = 6.

## Palindrome Number in Java Example.

by Dinesh Thakur Category: Control Structures

The Java Example to check if a Number is a palindrome or not.  A Number is palindrome if it remains unchanged when it is reversed, for example "151" is a palindrome as its reverse is "151".

## Factorial of the Given Number in Java Example

by Dinesh Thakur Category: Control Structures

Factorial Number is the product of natural numbers from one to that particular number.  Mathematically, n! = 1 * 2 * 3 * .... * (n-1) * n

## Fibonacci Series Using Recursion in Java Example

by Dinesh Thakur Category: Control Structures

Fibonacci Series is series of Natural Number in the Sequence of: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55...., The first two number in Fibonacci series are 0 and 1, where next number is equivalent to sum of previous two number. in this example we use Recursion method , Recursion means calling the same function again and again to reduce the complexity of the problem solved.

## Fibonacci Series in Java Example

by Dinesh Thakur Category: Control Structures

Fibonacci series numbers are in the following Sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144..., The first two number in Fibonacci series are 0 and 1, and each subsequent next number is the sum of the previous two Numbers.

## Find Recursion Power(x,n) Using Java Example

by Dinesh Thakur Category: Control Structures

step 2: Set r= 1

step 3: If value of n is 1 then print n and goto step - 8

step 4: Repeat through step-6 until j > 0

step 5: r=r*i

step 6: Update j as j=j-1

step 7: Print r

step 8: Exit

## Write a Java program for triangle of asterisks with maximum length of user input

by Dinesh Thakur Category: Control Structures

## Control statements in java

by Dinesh Thakur Category: Control Structures

Different types of control statements: the decision making statements (if-then, if-then-else and switch), looping statements (while, do-while and for) and branching statements (break, continue and return).

## Differences between Final, Finally and Finalize in Java

by Dinesh Thakur Category: Control Structures

final: Variables are useful when you need to store information that can change as the program runs. However, there may be certain situations in the program in which the value of the variable should not be allowed to modify. It is accomplished using a particular type of variable known as the final variable. The final variable also called constant variable. It is a variable with a value that cannot modify during the execution of the program.

Page 4 of 4

Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles