Tagged: Beginner

0

Java Program to find Sum the elements of an Array

Objective: Given an array of integers, write a java program to find the sum of all elements Example: Input [] = {20, 30, 40, 10, 5, 2, 60, 73} Output: 240 Approach: Do a...

0

Insertion Sort – Java Implementation

What is Insertion Sort?? Insertion sort is a simple sorting algorithm that builds the sorted array one item at a time. Efficient for small data sets, not efficient for large data sets. Most of...

1

Find Largest and Smallest word in a given String

Objective: Given a String, write a program to find the largest and smallest word in it. Example: Input String: test Smallest Word: test Largest Word: test —————— Input String: This problem is solved at...

0

Check if Given Number is power of 2.

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

0

Print First n numbers in Fibonacci Series

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

0

Find the Area and Perimeter of Rectangle – Java Program

A rectangle is a quadrilateral with four right angles. Say rectangle is given with side’s length A and B Area of Rectangle = A * B Perimeter of rectangle = 2(A+B) Code: Run This Code Output: Area of Rectangle:...

0

Reverse the given String using Stack

Objective: Given a String, write a java program to reverse the string using Stack Example: Input: “tutorial horizon” Output: “noziroh lairotut” Recommended: Please read Stack Data Structure before continue to read. Approach: Initialize a...

2

Stack Data Structure – Introduction and Implementation

What is Stack?? Stack is an abstract data type (ADT) and very useful in programming. In computer science, a stack is an abstract data type that serves as a collection of elements. Majorly all the operations are done at only one...

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

%d bloggers like this: