Tagged: Beginner

0

Calculate Log2n without using built-in function

Objective: Given a number n, write a program to calculate Log2n without using built-in function. Example: N = 32 Log232 = 5 N = 64 Log264 = 6 Approach: Initialize result = 0. Keep...

0

Print My IP Address – Java Code

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...

2

Linear Search Algorithm

Objective: Given an array [] of n elements and a element ‘x’, write a program to search an element ‘x’ in the array. Example: Input [] = {20, 30, 40, 10, 5, 2, 60,...

0

Floyd’s Triangle – Java Implementation

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...

0

Java Program to determine if Given Year is Leap Year

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...

2

Find the Area of a Circle – Java Program

Area of a circle = πR2 Where π = 3.14 and R = radius of circle Example: Radius = 4.0 Area = π*radius*radius = 3.14*4*4 = 50.24 Code:Run This Code Output: Area of circle...

0

Fizz Buzz Challenge – Java Implementation

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: