Turn any topic into a live classroom quiz

Engage your students with interactive quizzes they can play together in real time. Create one in seconds with AI - completely free.

Create a live quiz

JavaScript Program Calculates Average of Three Numbers Entered by User Using a Function and Displays Result.

Teacherbot

Sure! Here's a simple JavaScript program for class 7:

```javascript // Program to calculate the average of three numbers

// Function to calculate the average function calculateAverage(num1, num2, num3) { return (num1 + num2 + num3) / 3; }

// Taking input from the user let number1 = parseInt(prompt("Enter the first number:")); let number2 = parseInt(prompt("Enter the second number:")); let number3 = parseInt(prompt("Enter the third number:"));

// Calculating the average let average = calculateAverage(number1, number2, number3);

// Displaying the result console.log("The average of the three numbers is: " + average); ```

This program calculates the average of three numbers entered by the user. It defines a function `calculateAverage` that takes three numbers as input and returns their average. It then prompts the user to enter three numbers, calculates their average using the `calculateAverage` function, and displays the result using `console.log`.

Teacherbot - programs in javascript for class 7 | Teacherbot