# Hanging at home trying to make a code for fun

Page 1 of 1

## 5 Replies - 616 Views - Last Post: 28 April 2010 - 05:27 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=170906&amp;s=475dfc5668fa46dc5e2f781b997f9eb2&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 sauske

Reputation: -1
• Posts: 3
• Joined: 28-April 10

# Hanging at home trying to make a code for fun

Posted 28 April 2010 - 05:19 PM

I need help with a standard deviation program. im using visual studion 2008. I have been having problems making it work properly. I need it to compute the mean for the data set 1st. then computer the deviation by subtracting the mean from each value 2nd. square each individual deviation 3rd. add up te square deviations 4th. divide by one less than the sample size 5th. take the square root 6th. [20, 30, 10, 50, 60]

i need to make into array and calculate the SD (using functions) Sum() Avg() calc (subtracting the square root) and calcualte (using loops) 1. Avg 2. Max 3. Min i can make this a serperate program but i cant get it to work can anyone help me out i need it done today. Thank you.

```#include <iostream
#include <string>
#include <cmath>

using namespace std;

int main()
{

bool	more	= true;
int		count	= 0;
double	sum		= 0;

float	num		= 0.0;
double	avg		= 0;
double	s_dev	= 0;

cout << " Enter a value: (CTRL-D to quit): ";

cin >> num;

while (true)

{

++count;
cout << count << endl;

sum += num;

cout << " Enter a value: (CTRL-D to quit): ";
cin >> num;

if  (cin.eof())
{
break;
}

}

avg = sum / count;

s_dev = sqrt((( pow(sum,2.0)) -(( 1.0/count) * (pow(sum,2.0)))) / (count - 1.0)
);

cout << endl << endl;

cout << " There are " << count << " values. " << endl;

cout << " The average is:  " << avg << endl;

cout << " The standard deviation is:  " << s_dev << endl;

return 0;

}
```

Reason need it done today is cause a friend is leaving to China soon and needs it for statistics? idk i told him id make him something to use and no luck lol

This post has been edited by JackOfAllTrades: 28 April 2010 - 05:22 PM
Reason for edit:: Added code tags.

Is This A Good Question/Topic? 0

## Replies To: Hanging at home trying to make a code for fun

### #2 jjl

• Engineer

Reputation: 1130
• Posts: 4,686
• Joined: 09-June 09

## Re: Hanging at home trying to make a code for fun

Posted 28 April 2010 - 05:22 PM

Quote

Reason need it done today is cause a friend is leaving to China soon and needs it for statistics? idk i told him id make him something to use and no luck lol

that is the biggest load of crap i have ever heard. Do you know what a network is? you can also email to him if he existed. You dont have to be scared to say that you need help on your homework

Can you fix your code by pasting is in the appropriate code tags?

### #3 sauske

Reputation: -1
• Posts: 3
• Joined: 28-April 10

## Re: Hanging at home trying to make a code for fun

Posted 28 April 2010 - 05:24 PM

I need it done today cause friend is leaving to chine soon and needs it for statistics? lol anyway i told him id make him something to use and i havent goten it done lol thnak you.

• Saucy!

Reputation: 6219
• Posts: 23,965
• Joined: 23-August 08

## Re: Hanging at home trying to make a code for fun

Posted 28 April 2010 - 05:24 PM

Quote

Hanging at home trying to make a code for fun

LOL. Uh-huh. And you need it right away...for a friend leaving for China. Wow.

### #5 jjl

• Engineer

Reputation: 1130
• Posts: 4,686
• Joined: 09-June 09

## Re: Hanging at home trying to make a code for fun

Posted 28 April 2010 - 05:26 PM

This post has been edited by ImaSexy: 28 April 2010 - 05:27 PM

### #6 sauske

Reputation: -1
• Posts: 3
• Joined: 28-April 10

## Re: Hanging at home trying to make a code for fun

Posted 28 April 2010 - 05:27 PM

ImaSexy, on 28 April 2010 - 04:22 PM, said:

Quote

Reason need it done today is cause a friend is leaving to China soon and needs it for statistics? idk i told him id make him something to use and no luck lol

that is the biggest load of crap i have ever heard. Do you know what a network is? you can also email to him if he existed. You dont have to be scared to say that you need help on your homework

Can you fix your code by pasting is in the appropriate code tags?

well its not homework but i do need help