Skip to content

Q1 - Average of Three Numbers

Calculate the average of three numbers entered by the user.

package DSA.Practice_questions.VARIABLES_and_DATA_TYPES_QUESTIONS;
/*Question1:Inaprogram,input3numbers:A,BandC.Youhavetooutputtheaverageofthese 3 numbers.(Hint : Average of N numbers is sum of those numbers divided by N)*/
import java.util.*;
public class question1 {
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int avg = (a + b + c) / 3;
System.out.println(avg);
}
}
}