1
7 write a
program to input three
integers and find the difference
between their sum and their
average.
Answers
The following codes have been written using Python.
a = int(input("Enter an integer: "))
b = int(input("Enter a second interger: "))
c = int(input("Enter a third integer: "))
s = a + b + c
print()
print(s, "is the sum of the three integers.")
avg = (a + b + c)//3
print(avg, "is the average of the three integers.")
if s > avg:
d = s - avg
print(d, "is the difference between the sum and the average.")
elif avg > s:
d = avg - s
print(d, "is the difference between the sum and the average.")
Answer:
JAVA:-
Explanation:
import java.util.*;
class Brainly
{
static void main()
{
Scanner sc=new Scanner(System.in);
int a,b,c,s;
float av,d;
System.out.println(“Enter 3 integers:”);
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
s=a+b+c;
av=s/3f;
d=s-av;
System.out.println(“Difference=”+d);
}
}