Write a java program to find sum of digits of a number. Given an input number, we have to write a java code to calculate sum of digits of a number.

For example –

i)

Input : 256

Output : 13 (2+5+60

ii)

Input : 15

Output : 6 (1+5)

Technology Blog Where You Find Programming Tips and Tricks

Write a java program to find sum of digits of a number. Given an input number, we have to write a java code to calculate sum of digits of a number.

For example –

i)

Input : 256

Output : 13 (2+5+60

ii)

Input : 15

Output : 6 (1+5)

Write a program to find largest sum contiguous subarray. Given an array of N elements, find the maximum possible sum of a contiguous subarray. An array can contain both positive and negative values.

For example –

Let’s take an array whose values are { 1, 2, -5, 4, 3, 8 , 5 }

The maximum sum of a sub–array in this array is 20. And the sub–array is (4, 3, 8, 5).

Write a c program to print prime numbers from 1 to N (where n is an integer). This question can also be asked like, print prime numbers from 1 to 100 in c. In this tutorial, we are going to use sieve algorithm to print prime numbers from 1 to N.

Suppose the value of N is 10, So the prime numbers between 1 to 10 is 2, 3, 5, 7.

Now, Let’s learn how to print prime numbers from to 1 to N using **Sieve of Eratosthenes**. Before solving this program, let’s understand what is a prime number.

Write a program to delete a linked list. Given a linked list, we have to write a code to delete a linked list.

To delete a complete linked list, traverse all the nodes of a linked list and delete one by one.

Print Middle Element of a Linked List

To delete a node one by one maintain **two pointers**. The first pointer points to head and the second pointer keeps the reference to next node. So when a node is free, you can assign the reference of next node using the second pointer.

Write a java program to find duplicate elements in an array. Given an array of integers, We have to write a code to find all duplicate elements in an array.

For example :

Input : arr = { 2, 5, 3, 1, 8, 7, 5, 3, 2 }

Output: {5, 3, 2}

In this tutorial, I am going to explain three approaches to find duplicate elements in an array. This question is also very important for technical interviews.

Bubble Sort program, Algorithm & their time complexity.In this tutorial, We are going to learn about bubble sort algorithm and their implementation in various programming languages.

In this tutorial, we are going to cover following things

- What is Bubble Sort?
- Bubble sort algorithm & it’s time complexity
- Bubble sort program in C & C++
- Bubble sort implementation in PHP

Bubble sort is a sorting algorithm, It works by comparing each pair of adjacent elements and switching their positions if necessary. It repeats this process until all the elements are sorted.