Computer Science, asked by aatmaja7104, 10 months ago

Write a program to calculate the average of 5 numbers entered by the visitor through a prompt?

Answers

Answered by fuzailshaikh92
1

Answer:

<html>

<body>

<script type="text/javascript">

function show_prompt() {

i = 0;

do {

var number = prompt("Please Enter a Number");

var number = parseInt(number);

i++;

document.write("Number: " + number);

document.write("<br>");

}

while (i < 5);

}

show_prompt();

var avrg = number + number + number + number + number

document.write('Average of scores : ' + avrg);

</script>

</body>

</html>

Explanation:

Please make this answer Brainliest

Answered by shilpa85475
1

These are 2 ways to resolve this question, and you don't need to enter the total number of items you wish to find the sum using the loop since 5 inputs had already been decided on by the user.

Explanation:  

SUM= a+b+c+d+e

AVERAGE= (a+b+c+d+e)/5

Therefore, code will be

void main()

{

int a,b,c,d,e,sum,avg;

printf(“Enter the 5 numbers:”);

scanf(“%d%d%d%d%d”,&a,&b,&c,&d,&e);

sum=a+b+c+d+e;

avg=(a+b+c+d+e)/5;

printf(“\n Sum is:”,sum);

printf(“\n Average is:”,avg);

}

Therefore, now consider the 5 numbers as a, b, c, d, e.

Similar questions