Java Program to Reverse a Number

Here you will get java program to reverse a number with while loop and recursion. When we divide a number with 10 then the remainder is the last digit of number and quotient is the number without last digit. / operator is used find quotient and % operator is used to find remainder. We use this concept to reverse the number. Example: Initially n = 123, reverse = 0 Step 1: remainder = n % 10 = 123 % 10

Read more

Java Program for Leap Year

Here you will get java program for leap year. Condition for Leap Year A year completely divisible by 400 is leap year. A year completely divisible by 4 but not divisible by 100 is leap year. For example: 2000, 2008, etc are leap year while 1900, 1997, etc are not leap year. Java Leap Year Program

  Output Enter a year (Ex: 1990): 1996 leap year Enter a year (Ex: 1990): 1900 not leap year

Read more

Java Program to Find Largest of Three Numbers

Here you will get java program to find largest of three numbers using if else statements.

  Output Enter three numbers: 4 10 5 Largest number is 10

Read more

Java Program to Check Even or Odd Number

Here you will get java program to check even or odd number. How to check? If number is completely divisible by 2 then it is even otherwise odd. In our program we will find the remainder of number by dividing it by 2 using modulus (%) operator. If remainder is 0 then number is even else odd. Java Program to Check Even or Odd Number

  Output Enter a number: 4 even number

Read more

Java Program to Calculate Area and Circumference of Circle

Here you will get java program to calculate area and circumference of circle. Formula used: Area of Circle = 3.14 * radius2 Circumference of Circle = 2 * 3.14 * radius

  Output Enter radius: 3.5 Area = 38.465 Circumference = 21.98

Read more

Java Program to Swap Two Numbers Without Using Third Variable

Here you will get java program to swap two numbers without using third variable or temporary variable. We can do this in 3 ways as mentioned below. Also Read:┬áJava Program to Swap Two Numbers Using Temporary Variable   1. Using Addition & Subtraction Operator We can swap two numbers using addition (+) and subtraction (-) operator.

Output Before swap: a = 5 b = 6 After swap: a = 6 b = 5   2. Using Multiplication & Division

Read more

Java Program to Swap Two Numbers

Here you will get java program to swap numbers using temporary variable. It can be done in following way. temp = a a = b b = temp Also Read: Java Program to Swap Two Numbers Without Using Third Variable

  Output Enter first number: 5 Enter second number: 8 Before swap: a = 5 b = 8 After swap: a = 8 b = 5

Read more

Java Program for Addition of Two Numbers

Here you will get java program for addition of two numbers. It is the very basic java program that is useful for beginners.

  Output Enter first number: 8 Enter second number: 4 Sum = 12

Read more
1 7 8 9 10 11 14