473,473 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to develop a algorithm for mean value

7 New Member
I am facing a problem on how to develop a algorithm for mean value.
Since the numbers are entered by the user, in other word,the user can enter the number as their wish. Beside that, i also need to find the maximum value from the numbers that entered by the user
Mar 10 '10 #1
5 4152
whodgson
542 Contributor
What sort of mean value? geometrical, arithmetical, harmonic...?
loop until n=-99
{ get an integer
if(=-99)break
prod *=integer
count++
}
the geom_mean=pow(prod,1/count)..........i think!
assuming geom_mean, prod and count are double types.
Mar 10 '10 #2
ballpen1019
7 New Member
actually the mean value is the average value for a series of numbers that entered by the user..
the problems are
1) i need to calculate the average value from the numbers that enter by the user and the user can enter any numbers as their wish...in other word, i do not know how many numbers that the user will enter into the program.
2) average value=(x1+x2+.......Xn)/n, how can i transform this equation into machine language that allow the user to enter the value as they wish and calculate the average value in C programming.

so..i hope someone can answer my question as soon as possible.
Thank u
Mar 11 '10 #3
donbock
2,426 Recognized Expert Top Contributor
There are two basic strategies:
  1. Acquire all of the inputs from the user and then perform your calculations.
  2. Fold each user input into intermediate calculations as soon as it is entered.
In the first case you need a place to put all those input values -- either a static array sized for the maximum allowable number of inputs or dynamic storage that grows as more values are entered.

In the second case you need to verify that your particular calculation can be accomplished in this as-you-go manner. Not all calculations can be done this way.
Mar 11 '10 #4
whodgson
542 Contributor
how to develop a algorithm for mean value..
As you are aware an algorithm is not C or C++ code, it is an expression of the logic to be followed to achieve the desired result.
for example the following is an algorithm to convert from decimal to binary.
1. assert x>0.
2. set k=0.// k is a subscript
3. if x is odd, set b[k]=1. otherwise set b{k]=0.
4.subtract b[k] from x.
5. divide x by 2.
6 add 1 to k.
7. if x>0 repeat steps 3-6.
8. return b[k]......b[2]b[1]b[0].
so in your case........to be practical you have to limit the number of integers input.
1. enter an integer.
2. keep count of number or integers input
3. maintain a running total.
4. repeat 1-2 until Ctrl+Z is pressed (this completes input and gives count a final value).
5. Calculate mean (running total / count).
6. print mean.
Was this the sort of thing you were looking for?
Mar 12 '10 #5
ballpen1019
7 New Member
thank you so much...mr whodgson and donbock.....
Mar 12 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Jay | last post by:
Hey Guys, I need an algorithm/formula to do the following: I have two 32-bit timers cascaded to form a 64-bit timer, max value per timer(50sec). This is the way they work: value | timer1 |...
14
by: Tiza Naziri | last post by:
Hi, Anybody have an idea on how to start writing a C code for generating the inverse of finite field GF(2^8) using extended Euclidean algorithm? What I mean is how to represent a polynomial,...
113
by: Bonj | last post by:
I was in need of an encryption algorithm to the following requirements: 1) Must be capable of encrypting strings to a byte array, and decyrpting back again to the same string 2) Must have the same...
0
by: Sakharam Phapale | last post by:
Hi All, I am developing my own text editor using RichTextBox control. I don't want to use RichTextBox Undo and Redo functions. Instead of that I want to develop my own algorithm for Undo & Redo,...
1
by: Joe | last post by:
Has anyone written a percentile rank algorithm that they can share or know of a good resource that defines the algorithm. I'm starting a project that involves percentile ranks, logistic and linear...
17
by: silverburgh.meryl | last post by:
I have a function which calculate standard deviation. I am trying to re-write it using STL algorithm. I am thinking of using for_each() algorithm, but that will require my function passing in to...
4
by: FBM | last post by:
Hi, I am working on a program that simulates one of the elements of ATM. The simulation stores events which occurs every some milliseconds for a certain amount of time. Every time that an event...
4
prometheuzz
by: prometheuzz | last post by:
Hello (Java) enthusiasts, In this article I’d like to tell you a little bit about graphs and how you can search a graph using the BFS (breadth first search) algorithm. I’ll address, and...
32
by: =?ISO-8859-1?Q?Szabolcs_Horv=E1t?= | last post by:
I did the following calculation: Generated a list of a million random numbers between 0 and 1, constructed a new list by subtracting the mean value from each number, and then calculated the mean...
11
by: Dijkstra | last post by:
Hi folks! First, this is the code I'm using to expose the problem: ------------------------------------------------------------------ #include <functional> #include <string> #include...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.