Write a code segment (block) using C++ to calculate the average of 10 numbers provided by the user
Answer:
First, 10 numbers are taken input from the user and added to the sum variable one by one.
Then, average is calculated by dividing the sum by 10.
Here is the code with comments to explain the working.
Code Segment:
#include <iostream>
using namespace std;
int main()
{
int sum=0; //Sum variable to keep adding the numbers given by the
user
cout<<"Enter 10 numbers: "<<endl;
for(int i=0; i<10; i++) //Loop to take input 10 numbers and
adding them to sum one by one.
{
int n;
cin>>n;
sum = sum +n;
}
float avg = (float)sum/(float)10; //Calculating and storing average
of numbers using sum of numbers.
cout<<"Average is: "<<avg<<endl; //Printing the
average of numbers.
return 0;
}

Output:

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!
please comment if you have any doubts!
Write a code segment (block) using C++ to calculate the average of 10 numbers provided by...
Write a code segment to calculate the total product of 15 numbers provided by the user. Code block for programming
write a code segment for a loop to calculate the sum of first 10 odd numbers [what your program computes is 1+3+5+7+9+11+13+15+17+19. store the result in register r0.] it’s assembly language
Using Python The variables x and y refer to numbers. Write a code segment that prompts the user for an arithmetic operator and prints the value obtained by applying that operator to x and y. Using the following information run an example in Python Idle op = input("Enter an arithmetic operator: ") if op == "+": print(x + y) elif op == "-": print(x – y) elif op == "*": print(x * y) elif op == "/":...
Write a C++ segment of code in main () that reads a file called "numbers txt". You should cout the range of the numbers in the file, for example if the file contained "3.5 1.8 15" the range of numbers is 15 - 1.8 = 13.2.
Write pseudo code that will read in 3 numbers that a user enters, pass them to a module that will calculate the average of the 3 numbers and display them OR Write pseudo code that will read in 3 numbers that a user enters, pass them to a function that will calculate the average of the 3 numbers and return it to the main module. Display the average in the main module.
Write a program in C++ to calculate the average (mean) and the standard deviation of a list of numbers using vectors. Your program should... Prompt for the number of values the user wishes to enter Prompt the user to enter the values one at a time for the number of requested values into a vector Calculate and display the Mean and Standard Deviation The flow of your code should be similar to: int main() { /** Prompt the user and...
use c++ language, keep it simple i am using code block
Exercise#2: Arrays with Random Numbers Write a program that generates n random numbers as follows: Asks the user to input a positive integer n Asks the user to input the maximum value (say m) for the integers to be generated. Write a program that generates the n numbers in the range 0 to m. The program stores the generated numbers in an array A[ Asks the user to enter...
(C++ Microsoft Visual Studio) [15 Points] Write a while loop to calculate the average of numbers entered by the user: Ask the user to enter an integer number or -1 to stop Add the entered numbers Compute the average of the numbers outside the loop after termination Print the average
Please use C programming to write a code segment as an answer. Instead of using an while-loop like the following code, please implement a code segment by using a do-while loop. What is the output of the code? #include <stdio.h> void main() { int i = 0; while (i < 5); { printf(“%d ”, ++i); } }
write a program code that asks the user how many numbers they wish to find the statistics of and then asks the user to enter those numbers. The program must then calculate and display the average variance and standard deviation of the numbers entered by the user. the program code must -ask three user how many numbers they wish to find the statistics of -ask the user to enter those numbers and store them in an array - use a...