Skip to content

Instantly share code, notes, and snippets.

@codepainkiller
Created August 31, 2015 17:34
Show Gist options
  • Select an option

  • Save codepainkiller/f08fbb2c3ee58cf1f4a6 to your computer and use it in GitHub Desktop.

Select an option

Save codepainkiller/f08fbb2c3ee58cf1f4a6 to your computer and use it in GitHub Desktop.
Random Accumulator
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int randomAccumulator()
{
int suma = 0;
int randNumber = 0;
int temp = 0;
do{
suma += randNumber;
randNumber = 1 + rand() %(100);
temp = suma + randNumber;
}while(temp < 10000);
return suma;
}
int main()
{
srand(time(0));
cout << randomAccumulator() << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment