Computer Science, asked by HamadAmjad, 1 month ago

Write a program that inputs five integers from user and prints the smallest and largest number with average of remaining integers.​

Answers

Answered by Equestriadash
48

The following co‎des have been written using Python.

#creating a list for the integers

l = list()

#starting a loop to input the integers

for i in range(5):

   n = int(input("Enter the integer: "))

   #appending the integer into the list

   l.append(n)

   print()

print()

print(l, "is your given list of integers.")

print()

#sorting the list to obtain the smallest and largest integers

l.sort()

print(l[0], "is the smallest integer.")

print(l[-1], "is the largest integer.")

#calculating the average of the remaining integers

sn = sum(l[1:-1])

avg = sn/3

print(avg, "is the average of the remaining integers.")

Answered by BrainlyProgrammer
37

Answer:-

//Java Program to print the smallest and the largest number with average of remaining numbers.

import java.util.*;

class Avg{

public static void main (String ar[]){

Scanner sc=new Scanner (System.in);

int max=0,min=999999;

double avg=0;

int s=0,d=0,p=0;

int k[]=new int [5];

for(int I=0;I<5;I++){

k[I]=sc.nextInt();

}

for(int I=0;I<5;I++)

{

if ( k[I]<min){

min=k[I];

p=I;

}

else if (k[I]>max){

max=k[I];

d=I;

}

}

for(int I =0;I<5;I++){

if((k[I]!=k[d])||(k[I]!=k[p]))

s+=k[I];

}

avg=s/3;

System.out.println("Largest:"+max);

System.out.println("Smallest:"+min);

System.out.println("Average:"+avg);

}

}

Output Attached.

•••♫

Attachments:
Similar questions