English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Full question:
Write a program that inputs 10 integers into an array. Calculate and output the average of the 10 integers entered and a count of how many input values are greater than the average. You are also required to print the numbers from the array all on the same line.

If given the same inputs as shown in the example run below, your program should produce the same output
The user's input data is shown in boldface.

Please enter a number: 89
Please enter a number: 56
Please enter a number: 12
Please enter a number: 22
Please enter a number: 23
Please enter a number: 92
Please enter a number: 55
Please enter a number: 18
Please enter a number: 29
Please enter a number: 63
Numbers from array: 89 56 12 22 23 92 55 18 29 63
Average of the numbers entered : 45.9
Number of input values greater than the average : 5
Note : You must use FOR loop(s) for ALL array handling.

2007-03-12 05:07:48 · 2 answers · asked by Facilitate 1 in Computers & Internet Programming & Design

2 answers

Logic code:

array number;
variable data;
variable sum;
variable average;
variable count;

For A from 0 to 10 do
prints message requesting for inputing numbers
read data;
number stores data;
end For

For B from 0 to 10 do
read data from array number;
sum receives sum value plus number value;
end For

average receives the result of the operation sum / 10;

For c from 0 to 10 do
read a number array number;
prints the number on screen;
end For

For D from 0 to 10 do
read a number from array number
if the number is higher than the average
then increment the count variable;
else doesn't do anything
end for

prints message about the average ;
prints message about the count variable and the number of values that are higher than the average;

2007-03-12 07:34:23 · answer #1 · answered by Anonymous · 0 0

int i,no[8],min,max,even,strange; void oddeven() { even=0,strange=0; for(i=0;i<8;i++) if(a[i]%2==0) even++; else strange++ } void multi_calculate() { min=0; max=0; for(i=0;i<8;i++) { if(a[i]>a[max]) max=i if(a[i]a hundred ||a[i<0) { printf("blunders"); go out(0); } } multi_calculate(); printf("min=%d,max=%d",a[min],a[max]); oddeven(); printf("no of unusual=%d,no of even=%d",strange,even); }

2016-10-18 04:48:50 · answer #2 · answered by ? 4 · 0 0

fedest.com, questions and answers