Code:
# include <stdio.h>
# include <stdlib.h>
# include <time.h>

int main(void)
{
  int ans, val, ctr;
  srand((unsigned) time(NULL));
  val = (rand() % 6) + 1;
  ans = 0;
  ctr = 0;
  while(ans != val && ctr < 3)
  {
    printf("Enter a value between 1 and 6  :  ");
    fflush(stdin);
    scanf("%d", &ans);
    puts("");
    ctr++;
  }
  if(ans == val)
  {
    printf("You Guessed correct in %d guesses!\n", ctr);
  }
  else
  {
    printf("Too Many Guesses!!!\n");
  }
  fflush(stdin);
  getchar();
  return 0;
}


Edited by Gizmo: Added [code] tags.


Edited by Gizmo (11/09/06 03:33 AM)
_________________________
Hacking is an art that is to be mastered to get the rewards from it!
----Virtual Ranger - VR----