Skip to content

Commit

Permalink
finding the differnece between the maximum and minimum value input
Browse files Browse the repository at this point in the history
  • Loading branch information
suhanigupta23 authored Feb 4, 2024
1 parent 381a5e6 commit 80314b6
Showing 1 changed file with 33 additions and 0 deletions.
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);
}
}

0 comments on commit 80314b6

Please sign in to comment.