C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Largest And Smallest Number Program Using Java With I/O Stream
WhatsApp
Senthilvelan Sambamoorthy
5y
7.2
k
0
0
25
Blog
large.rar
Introduction
In this blog, I will explain about the largest and smallest number in the given array program, using Java. It is very simple in Java Programming. The output will be displayed in the Run module.
Software Requirement
JDK1.3.
Simple Program
import
java.io.*;
class
large {
public
static
void
main(String arg[])
throws
IOException {
DataInputStream dr =
new
DataInputStream(System.in);
System.out.println(
"Enter the size of Array : "
);
int
no = Integer.parseInt(dr.readLine());
int
a[] =
new
int
[no];
System.out.println(
"Enter the Elements of Array..."
);
for
(
int
i =
0
; i < no; i++) {
a[i] = Integer.parseInt(dr.readLine());
}
int
small = a[
0
];
int
large = a[
0
];
for
(
int
i =
0
; i < no; i++) {
if
(a[i] > large)
large = a[i];
else
if
(a[i] < small)
small = a[i];
}
System.out.println(
"The Smallest Number of the given array is : "
+ small);
System.out.println(
"The Largest Number of the given array is : "
+ large);
}
}
Explanation
In this blog, I will explain about the largest and smallest number in the given array program using Java. The output will be displayed in the Run module.
Output
Java
I/O Stream
Recommended related topics
Membership not found