-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finding the differnece between the maximum and minimum value input
- Loading branch information
1 parent
381a5e6
commit 80314b6
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
span_finding_difference_between_maximum_and_minimum_value_input.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//FINDING THE DIFFERNECE BETWEEN THE MAXIMUM AND MINIMUM VALUES INPUT (SPAN) | ||
|
||
|
||
import java.util.*; | ||
public class Program | ||
{ | ||
public static void main(String[] args) | ||
{ | ||
Scanner scn=new Scanner (System.in); | ||
int n=scn.nextInt(); | ||
int []arr=new int [n]; | ||
|
||
for(int i=0;i<arr.length;i++) | ||
{ | ||
arr[i]=scn.nextInt(); | ||
} | ||
int max=arr[0]; | ||
int min=arr[0]; | ||
for(int i=1;i<arr.length;i++) | ||
{ | ||
if(arr[i]>max) | ||
{ | ||
max=arr[i]; | ||
} | ||
if(arr[i]<min) | ||
{ | ||
min=arr[i]; | ||
} | ||
} | ||
int span=(max-min); | ||
System.out.println(span); | ||
} | ||
} |