## Java program for increment and decrement (pre and post)

Learning the operators of the Java programming language is a good place to start. Operators are special symbols that perform specific operations on one, two, or three operands, and then return a result. Increment/Decrement operators: Increment and decrement operators are known as Unary operators. They require only one operand. Increment operator:… Continue Reading Java program for increment and decrement (pre and post)

## Java program to implement simple if-else

In programming, we execute certain section of code based on whether the specified condition is true or false which is known only at run time. For such cases we use “control flow statements”. Simple if if……else nested if if else if Simple if: Simple If statement is the most basic… Continue Reading Java program to implement simple if-else

## Java program to find Factorial of a given number using Recursion

Factorial: Factorial of a non-negative integer n, is the product of all positive integers less than or equal to n.  It is represented as n!. n! = 1 * 2 * 3 * 4 * ………………… * (n-1) * n. for example,  5! can be calculated as 5 * 4… Continue Reading Java program to find Factorial of a given number using Recursion

## Java program to swap two variables without using third variable

This program explains about how you can  swap  values within a variable without using the third variable. Algorithm: Step 1 : START Step 2 : Declare two variables, say a,b. Step 3 : Add a and b and store to a. Step 4 : Subtract b from a and store… Continue Reading Java program to swap two variables without using third variable

## Java program to find factorial of a given number

The Factorial of a non-negative number n is the product of all positive integers less than or equal to n and is represented by n!. n! = 1 * 2 * 3 * 4 * 5 * ………………………..  * (n-1) * n. for example 5! can be calculated as 1… Continue Reading Java program to find factorial of a given number

## Java program to swap two variables

In computer programming, the act of swapping of two variables refers to mutually exchanging the values of the variables. Algorithm: Step 1: START. Step 2: Declare a, b, temp. Step 3:Copy value of a to temp. Step 4: Copy value of b to a. Step 5: Copy value of temp… Continue Reading Java program to swap two variables

## Java Program to find product of two numbers

In this program, user is asked to enter two integers. Then, the product of those two integers is stored in a variable and displayed on the screen. Algorithm: Step 1: Start. Step 2: Declare variables, say a and b. Step 3: result = a * b. Step 4: Display result.… Continue Reading Java Program to find product of two numbers

## Java Program to print Hallow square pattern

Square frame pattern is designed in accordance to the number of rows user has entered. In this java program, the user is asked to enter number of rows. It displays a hallow square based on number of rows. Algorithm: Step 1: Start. Step 2: Read number of rows to be… Continue Reading Java Program to print Hallow square pattern

## Java program to check whether the given number is even or odd

A number is said to be even if it is divisible by 2.  otherwise odd. Let us now see an example of a java program to determine whether the given number is an odd or even number. Algorithm: Step 1: Start. Step 2:  Read n. Step 3:  if n%2 ==… Continue Reading Java program to check whether the given number is even or odd

## Java program to Generate Fibonacci sequence

A series of numbers in which each number is the sum of the two preceding numbers. for example 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 etc. The first two numbers of fibonacci series are 0 and 1. Algorithm: Step 1: START. Step 2: Declare variables a,b,c.… Continue Reading Java program to Generate Fibonacci sequence

## Java program to check whether the given number is prime or not

A number is said to be prime if it is divisible by 1 and itself. otherwise it is composite. Algorithm Step 1: START. Step 2: read the number n. Step 3: Check the divisibility of the number from 2 to n/2. Step 4: If number is divisible by any of… Continue Reading Java program to check whether the given number is prime or not

## Java program for Division of two numbers

In this Program the user is asked to enter two numbers. Based on the numbers the division of two numbers is per Algorithm: Step 1: Start. Step 2: Declare variables, say a, b and c. Step 3: c = a/b; Step 4: Display result. Step 5: Stop. Source code: import… Continue Reading Java program for Division of two numbers

## Java Program to add two numbers without using third variable

In this program user is asked to enter two integers and the sum operation is performed. Source code: import java.util.*; class Add { public static void main(String args[]) { int num1; int num2; System.out.println(“\n \n *** www.programmingposts.com *** \n \n”); System.out.println(“<< Addition of two numbers without using Third Variable >>… Continue Reading Java Program to add two numbers without using third variable

## Java Program to Add two integers

Let us now see an example of a java program to add two integers. In this program, user is asked to enter two integers. Then, the sum of those two integers is stored in a variable and displayed on the screen. For algorithm & flowchart for addition of two numbers,… Continue Reading Java Program to Add two integers