Click here to Skip to main content
15,922,894 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Make toolbars undockable Pin
ThatsAlok14-May-06 22:22
ThatsAlok14-May-06 22:22 
Question2 modems connection Pin
amir hossein malakouti13-May-06 2:36
amir hossein malakouti13-May-06 2:36 
AnswerRe: 2 modems connection Pin
Mohammad Tarik13-May-06 12:55
Mohammad Tarik13-May-06 12:55 
Questiontrouble with calculations Pin
lindag178313-May-06 2:30
lindag178313-May-06 2:30 
AnswerRe: trouble with calculations Pin
Justin Tay13-May-06 2:56
Justin Tay13-May-06 2:56 
GeneralRe: trouble with calculations Pin
lindag178313-May-06 15:10
lindag178313-May-06 15:10 
AnswerRe: trouble with calculations Pin
Gary R. Wheeler13-May-06 3:04
Gary R. Wheeler13-May-06 3:04 
GeneralRe: trouble with calculations Pin
lindag178313-May-06 15:16
lindag178313-May-06 15:16 
Hi Thanks for your reply. I have insert double instead of float but I still get the same mistakes. he mistakes sometimes are way off from the true answer, so onlsy sometimes are they close to the answer. In this case the answer came back way off again, by about 40! Anyway, I am sure my logic is correct so it mst be the code somehow. Please help.
Here is my code:

#include <iostream>
using namespace std;
int main(void)

{

double M, N, total, score1, score2, score3, score4, score5, score6, score7, score8, V1, V2, V3, V4, V5, V6, V7, V8, s1, s2, s3, s4, s5, s6, s7, s8, Variance;
cout << "Input the number of people in sample ";
cin >> N;
cout << "input the 1st score ";
cin >> score1;
cout << "input the 2nd score ";
cin >> score2;
cout << "input the 3rd score ";
cin >> score3;
cout << "input the 4th score ";
cin >> score4;
cout << "input the 5th score ";
cin >> score5;
cout << "input the 6th score ";
cin >> score6;
cout << "input the 7th score ";
cin >> score7;
cout << "input the 8th score ";
cin >> score8;
total = score1 + score2 + score3 + score4 + score5 + score6 + score7 + score8;
M = total / N;
cout << "the mean for these scores is: " << M << "\n";
s1 = score1 - M;
V1 = s1 * s1;
s2 = score2 - M;
V2 = s2 * s2;
s3 = score3 - M;
V3 = s3 * s3;
s4 = score4 - M;
V4 = s4 * s4;
s5 = score5 - M;
V5 = s5 * s5;
s6 = score6 - M;
V6 = s6 * s6;
s7 = score7 - M;
V7 = s7 * s7;
s8 = score8 - M;
V8 = s8 * s8;
cout << "the variance for these scores is: " << (double) (V1 + V2 + V3 + V4 + V5 + V6 + V7 + V8) / N << "\n";
return 0;

}
Confused | :confused:

linda
GeneralRe: trouble with calculations Pin
Gary R. Wheeler14-May-06 1:27
Gary R. Wheeler14-May-06 1:27 
GeneralRe: trouble with calculations Pin
lindag178314-May-06 4:44
lindag178314-May-06 4:44 
GeneralRe: trouble with calculations Pin
Gary R. Wheeler14-May-06 6:13
Gary R. Wheeler14-May-06 6:13 
GeneralRe: trouble with calculations Pin
lindag178314-May-06 15:33
lindag178314-May-06 15:33 
GeneralRe: trouble with calculations Pin
lindag178314-May-06 15:46
lindag178314-May-06 15:46 
GeneralRe: trouble with calculations Pin
Gary R. Wheeler15-May-06 13:00
Gary R. Wheeler15-May-06 13:00 
AnswerRe: trouble with calculations Pin
Stephen Hewitt13-May-06 5:47
Stephen Hewitt13-May-06 5:47 
AnswerRe: trouble with calculations Pin
Saurabh.Garg13-May-06 16:20
Saurabh.Garg13-May-06 16:20 
GeneralRe: trouble with calculations Pin
lindag178313-May-06 21:29
lindag178313-May-06 21:29 
GeneralRe: trouble with calculations Pin
Justin Tay13-May-06 23:59
Justin Tay13-May-06 23:59 
GeneralRe: trouble with calculations Pin
lindag178314-May-06 0:46
lindag178314-May-06 0:46 
GeneralRe: trouble with calculations Pin
Saurabh.Garg14-May-06 15:04
Saurabh.Garg14-May-06 15:04 
Questionmysql database Pin
J512198213-May-06 2:13
J512198213-May-06 2:13 
AnswerRe: mysql database Pin
Hamid_RT13-May-06 3:58
Hamid_RT13-May-06 3:58 
AnswerRe: mysql database Pin
Kleser13-May-06 4:56
Kleser13-May-06 4:56 
Questiongetstdhandle returns INVALID_HANDLE_VALUE Pin
e_prabhu13-May-06 2:02
e_prabhu13-May-06 2:02 
AnswerRe: getstdhandle returns INVALID_HANDLE_VALUE Pin
Hamid_RT13-May-06 5:01
Hamid_RT13-May-06 5:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.