## Print Number with its Sign in Java

Sometimes we need to print the numbers with its sign irrespective of number is positive (+) or negative(-). Example: X = 5, print = +5 Y = -8, print = -8 Say we need...

Skip to content# Category: MISC

## Print Number with its Sign in Java

## Calculate Logn base r – Java Implementation

## Check if Given Number is power of 2.

## Print First n numbers in Fibonacci Series

## Find the Area of Triangle using base and height – Java Program

## Get the Sum of Digits in a number till it become a single digit

## Print First N Prime Numbers – Java Code

## Print My IP Address – Java Code

## Find the Circumference of a Circle – Java Program

## Check if two Strings are equal without using built-in function – Java

## Floyd’s Triangle – Java Implementation

## Print Numbers from 1 to N without using loop

## Swap two numbers using Bitwise XOR Operator

## Java Program to determine if Given Year is Leap Year

## Fizz Buzz Challenge – Java Implementation

@tutorialhorizon

Sometimes we need to print the numbers with its sign irrespective of number is positive (+) or negative(-). Example: X = 5, print = +5 Y = -8, print = -8 Say we need...

Objective: Given a number n and r, write a program to calculate Logrn Example: N = 32, r =2 Log232= 5 N = 64, r = 4 Log464= 3 Approach: Without using built-In function-...

Objective: Given a number, write a program to find if number is power of two. Example: N = 5 Output: false. N = 8 Output: true (23) N = 512 Output: true (29) Approach:...

Objective: Write a program to print first n numbers in Fibonacci series. Fibonacci number: First two Fibonacci numbers are defined as 0 and 1 and every number after the first two is the sum...

Objective: Given the base and height of a triangle, using math formula for calculating the area of triangle, write an java program to calculate the triangle area. Area of a Triangle: (Base * Height)/2...

Objective – Given a number, Write a program to get the sum of digits in a number till it become a single digit. Example: N = 999 -> 9+9+9 = 27-> 2+7 = 9...

Objective: Given a number N, write a program to print first N prime numbers. What is Prime number:?? A prime number (or a prime) is a natural number greater than 1 that cannot be...

Objective: Write a java program to print your IP address. Approach: Get the local host address of your system using getLocalHost() method. Use getHostAddress() method to get the IP address from local host address. Code:Run This Code...

Area of a circumference = 2πR Where π = 3.14 and R = radius of circle Example: Radius = 4.0 Area = 2*π*radius = 2*3.14*4 = 25.12 Java Code:Run This Code Output: Area of...

Objective– Given two strings, find out if they are equal or not without using any built-in function (without using equals() function in java). Example: String x=’tutorial’ and String y=’tutorial’ are equal – true String...

Floyd’s Triangle: Floyd’s triangle is a right angled triangular array of natural numbers. It named after Robert Floyd. Rows of the triangle filled by consecutive numbers. First row will have single number which is...

Objective: Given a number N, write an program to print from number 1 to N without using loop. Example: N = 20 Output: 1 2 3 4 5 6 7 8 9 10 11 12...

Objective– Given two numbers, swap both the numbers using XOR operators. Example: X = 4, Y = 8 Output: X = 8, Y= 4 Approach: XOR operator There are many ways to swap two...

Objective: Given a Year, write a java program to find whether year is leap year or not. Leap Year: a year, usually occurring once every four years, that has 366 days including February 29...

Objective: Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which...

%d bloggers like this: