Quote
Two dice are tossed 1000 times. Record the sum of the faces in an array. Print out the results and determine the probability of getting a sum of 7. 11?
and when I run my executable I get a message like in the attached picture.
I'm not really sure why. I can compile and run C++ programs in NetBeans with no problems!
My code:
/*
* File: 2a.cpp
* Author: James
*
* Created on January 27, 2009, 3:33 PM
*/
#include <stdlib.h>
#include <iostream>
#include <cmath>
#include <time.h>
using namespace std;
/*
*
*/
int main(int argc, char** argv) {
int arnSum[1000]; // sum of the faces
int arnProb[36];
int nDie1, nDie2;
for (int i=0;i<1000;i++) {
nDie1 = rand()*6+1;
nDie2 = rand()*6+1;
arnSum[i] = nDie1 + nDie2;
arnProb[nDie1+nDie2]++;
}
return (EXIT_SUCCESS);
}


Sign In
Create Account


Back to top









