•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 456,501 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,671 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 839 | Replies: 10 | Solved
![]() |
#include <cstring>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>
#include <ctime>
using namespace std;
int main()
{
double standardDev(int, int, int);
srand ( static_cast<unsigned int> ( time ( 0 ) ) );
int i,j;
int Low = 147;
int High = 206;
int numbers = 0;//the actual numbers
double avg = 0.0;//average of group of numbers
int count = 0;
int sum = 0;
int sumsquared = 0;
for (i=147; i < 207; i++)
{
count += 1;
numbers = rand() % (High - Low + 1)+ Low;
if (i%5==0)
cout << numbers << endl;
sum += numbers;
sumsquared += (numbers * numbers);
}
for (i=0;i<count-1;i++)
{
for (j=i+1;j>count; j++)
if (count>numbers)
swap (count,numbers);
}
if (count > 0)
{
avg = ((double) sum / (double) count);
cout << "\n\nCount is: " << count << endl;
printf("Average is: %.2f\n", avg);
printf("Deviation is: %.3f\n\n", standardDev(sum, sumsquared, count));
}
return 0;
}
// Function for calculating standard deviation
double standardDev(int sum, int sumsquared, int count) {
double deviation = (double) (sumsquared - ((sum * sum) / count));
deviation = deviation / (double) (count - 1);
double stndDev = sqrt(deviation);
return stndDev;
return 0;
} Thx for any assistance.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Random number generator's (C++)
- Getting a non-random number? (C++)
- creating random numbers (C)
- Calculator program returning random values (Assembly)
- random number generator and calculations (Java)
- Random Restarts (Windows NT / 2000 / XP / 2003)
- random numbers all different??? (C++)
Other Threads in the C++ Forum
- Previous Thread: Urgent solution needed
- Next Thread: An introduction and a few questions..



Linear Mode