Program to print the smallest element in an array17 Mar 2025 | 2 min read In this program, we need to find out the smallest element present in the array. This can be achieved by maintaining a variable min which initially will hold the value of the first element. Loop through the array by comparing the value of min with elements of the array. If any of the element's value is less than min, store the value of the element in min. ![]() Consider above array. Initially, min will hold the value 25. In the 1st iteration, min will be compared with 11. Since 11 is less than 25. Min will hold the value 11. In a 2nd iteration, 11 will be compared with 7. Now, 7 is less than 11. So, min will take the value 7. Continue this process until the end of the array is reached. At last, min will hold the smallest value element in the array. Algorithm
Program:Output: Smallest element present in given array: 7 Next TopicJava Programs |
In this program, we create a doubly linked list and insert a new node in the middle of list. If list is empty, both head and tail will point to new node. If list is not empty, then we will calculate the size of the...
8 min read
In this program, we create a circular linked list, then traverse the list in the reverse order and print the nodes. Algorithm Define a Node class which represents a node in the list. It has two properties data and which will point to the node. Define...
7 min read
In this program, we will create a singly linked list and delete a node from the middle of the list. To accomplish this task, we will calculate the size of the list and then divide it by 2 to get the mid-point of the list....
5 min read
It is a problem frequently asked in interviews of top IT companies like Google, Amazon, TCS, Accenture, etc. By solving the problem, one wants to check the logical ability, critical thinking, and problem-solving skill of the interviewee. So, in this section, we are going to discuss...
5 min read
Krishnamurthy number is another special number in Java. A number is said to be Krishnamurthy if the factorial sum of all its digits is equal to that number. Krishnamurthy number is also referred to as a Strong number. Just like Prime and Armstrong numbers, Krishnamurthy number...
3 min read
Implementing the Fibonacci series in Java is a classic programming exercise that provides an excellent introduction to recursion, dynamic programming, and mathematical concepts. In this section, we will explore different methods to implement the Fibonacci series in Java, discuss their advantages and disadvantages, and delve...
8 min read
In this section, we will learn what is an autobiographical number and also create Java programs to check if the given number is autobiographical or not. The autobiographical number program frequently asked in Java coding tests to check the logic of the programmer. Autobiographical Number A digit count...
4 min read
Java Program to divide a string in 'N' equal parts. Here, our task is to divide the string S into n equal parts. We will print an error message if the string cannot be divisible into n equal parts otherwise all the parts need to be...
3 min read
? In Java programming, we often required to generate random numbers while we develop applications. Many applications have the feature to generate numbers randomly, such as to verify the user many applications use the OTP. The best example of random numbers is dice. Because when we throw...
7 min read
In this program, we create a doubly linked list, and then reverse the list by reversing the direction of the list and print out the nodes. Traverse through the list by swapping the ious pointer with pointer of each node. Then, swap the position of...
6 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India