Please help:
tnis code has a logical error .
I am using rand function to generate random values from 1 to 5, funtion random generate random values and than this random values are checked by switch statement
that how many a numbers are repeatedly generated by that funtion,
logical error: when i try loop for 4 values (arraysize) result is correct when i try 5 to max values (arraysize) the result is not correct and when i a increment for loop to 14 values (arraysize) it prompt a message that program is stop working.
[/code]
#include <iostream>
#include<cstdlib>
#include<iomanip>
#include<ctime>
const int arrysize=8;
using namespace std;
int random(int rrandom[]){
int zero=0,one=0,two=0, three=0, four=0, five=0 ,six=0;
for(int o=0; o<=arrysize;o++)
{
switch(random_main[o]){
//cout<<random();
case 0: {zero++; break;}
case 1: {one++;break;}
case 2: {two++; break;}
case 3:{three++; break;}
case 4:{four++; break;}
case 5:{five++; break;}
}