mardi 31 janvier 2017

Random number between zero and one in c++

i want to create a random number between 0 and 1 but my codes output is zero.

#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

int main()
{
  srand(time(0));

  for(int x=0;x<100;x++)
  {
      cout<<(rand()%10)/10<<endl;
  }
  return 0;
}




Aucun commentaire:

Enregistrer un commentaire