[Solved] Write a method named “RollDie” that will return an integer in the range of 1 to 6 [closed]


Do something like

#include<stdio.h>
#include<time.h>


int rolldie()
{
  time_t t;
  int ret=0;
    while(ret==0)
    {
      sleep(3); 
      /* You need some time to roll the die. Don't you? 
       * practically srand is not that random in close intervals
       * That is the practical use of sleep() here.
       */
      srand((unsigned)time(&t));//Initialize rand no gen
      ret=rand()%7;
    }
return ret;
}

int main()
{
int c=0;
  while(c<6)
  {
     printf("Rolling the die.. Result : %d\n",rolldie());
     c++;
  }
return 0;
}

4

solved Write a method named “RollDie” that will return an integer in the range of 1 to 6 [closed]