1- Write a program to read 10 numbers and find the average of these numbers. Use a while loop to read these numbers and keep track of input numbers read. Terminate the while loop with a sentinel value.
2- Now modify the program to find the maximum of these numbers
as well. The program should print the number of elements read as
input and run until -1 is entered. (-1 is the sentinel that
terminates the loop and the program) To find the maximum, you want
to read the first number outside the loop and assign it to the max
variable.
As you read each number you must use the if statement and check it
against max.
In C language please.
Answer 1:
#include <stdio.h>
int main()
{
int sum=0,i,num;
// looping to take 10 values
printf("Enter 10 values");
for(i=0;i<10;i++){
scanf("%d",&num);
// adding to sum
sum+=num;
}
// printing average
printf("Average : %f ",sum/10.0);
return 0;
}

Answer 2:
#include <stdio.h>
int main()
{
int i,max,num;
printf("Enter values -1 to exit");
scanf("%d",&max);
// reading values
for(i=0;;i++){
scanf("%d",&num);
// if user enters -1, break the loop
if(num==-1)
break;
// checking with current max
if(num>max)
max=num;
}
printf("Number of values entered : %d \n",i+1);
printf("Max number : %d ",max);
return 0;
}

1- Write a program to read 10 numbers and find the average of these numbers. Use...
Write a program that calculates the average of a stream of non-negative numbers. The user can enter as many non-negative numbers as they want, and they will indicate that they are finished by entering a negative number. For this program, zero counts as a number that goes into the average. Of course, the negative number should not be part of the average (and, for this program, the average of 0 numbers is 0). You must use a method to read...
It needs to be done in JAVA
Please don't use the flag=true method. I need it done in another
way.
The user should input the number of numbers they are going to enter. Your job is to find the maximum and the minimum of these numbers. The output of the program if the user does not enter a negative number and all iterations successfully terminate, will be the maximum number, the minimum number and their difference(max-min). If the user inputs...
In C++
2. Write a program that allows the user to enter a series of positive numbers between 1 and 100 and displays the smallest and largest of the numbers entered. The program should not store the numbers that were entered, only keep track of the smallest and largest ones. The program should continue accepting numbers until the value 0 is entered and then display the results. If a number out of range is entered, tell the user it is...
Write a program that allows the user to enter a series of exam scores. The number of scores the user can enter is not fixed; they can enter any number of scores they want. The exam scores can be either integers or floats. Then, once the user has entered all the scores they want, your program will calculate and print the average of those scores. After printing the average, the program should terminate. You need to use a while loop...
•Write a java program to read
10 numbers and print them in reverse order. Modify your program to
work for N numbers given by the user Extend your program to find
the average of these numbers Extend your program to find the
smallest number of these numbers Extend your program to find the
largest number of these numbers
•Write a program to read 10 numbers and print them in reverse order. Modify your program to work for N numbers given...
Objectives:
Use the while loop in a program
Use the do-while loop in a second program
Use the for loop in a third program
Instructions:
Part A. Code a for loop to print the Celsius temperatures for
Fahrenheit temperatures 25 to 125. C = 5/9(F – 32).Output should be
in a table format:
Fahrenheit Celsius
25 ?
. .
. . . .
. .
Turn in the source and the output from Part A.
Part B. Code a while...
In C language using printf and scanf statements: Write a program to display a histogram based on a number entered by the user. A histogram is a graphical representation of a number (in our case, using the asterisk character). On the same line after displaying the histogram, display the number. The entire program will repeat until the user enters zero or a negative number. Before the program ends, display "Bye...". The program will ask the user to enter a non-zero...
(java) Write a While loop that prompts the user for only even numbers. Keep prompting the user to enter even numbers until the user enters an odd number. After the loop ends, print the sum of the numbers. Do not include that last odd number. You should not store the numbers in an array, just keep track of the sum. Make sure to use a break statement in your code. You may assume that a java.util.Scanner object named input has...
In java language: Ask for keyboard input of a decimal number. Use a loop to keep asking for input of up to ten numbers. Exit the loop if ten numbers are entered or if a sentinel value for “QUIT” is entered. Store the numbers in an array. Sort the array according to ascending number. Get the average for all the numbers in the array. Print out the average. Calculate the distance from the average for each number in the array...
This program is in C++ Write a program that validates charge account numbers read in from the file Charges.txt following this assignment (A23 Data). Use a selection sort function on the array to sort the numbers then use a binary search to validate the account numbers. Print out the sorted list of account numbers so you can see the valid ones. Prompt the user to enter an account number and the validate that number. If the account number entered is...