Write program to guess a random number seeded by current time.
A random number is generated to make the guessing game more interesting.
#include <stdio.h> #include <stdlib.h> #include <time.h> int main()/*from w w w.ja va 2 s.c om*/ { int r,guess; srand((unsigned)time(NULL)); r=rand(); printf("Can you guess the secret number: "); scanf("%d",&guess); if(guess==r) { puts("You guessed it!"); return(0); } if(guess!=r) { puts("Wrong!"); printf("The secret number was %d\n",r); return(1); } }