what code can I use to make a fortune cookie program that will give a random result when you input bday, month and year?

I'm new with this but this is what i typed first:

#include<conio.h>
#include<stdio.h>

main()
{
int dd,yy,mm;
clrscr();
printf("Know your Fortune Cookie reading");
printf("input birth day")
scanf("%d",&dd);
......
...
....

but idont know what formula to input to randomize my rsult since there are like over 20 readings i have.
im just familiar using If program
can i do that using this program\?

Using the stdlib.h header in conjunction with the time.h header you can generate pseudo-random numbers which will allow you to select a random fortune cookie.

#include <stdlib.h>
#include <time.h>

int main(void){
     srand( time(NULL) ); // seed the random generator, with current time, making it a different seed when run each time

     int myRandomValue = rand() % n; // returns a random number inclusive of the range 0..(n-1)
     
     return 0;
}

Since we are in the C++ forum lol, mistake by me. Make it ctime header and cstdlib :)

Chris

Using the stdlib.h header in conjunction with the time.h header you can generate pseudo-random numbers which will allow you to select a random fortune cookie.

#include <stdlib.h>
#include <time.h>

int main(void){
     srand( time(NULL) ); // seed the random generator, with current time, making it a different seed when run each time

     int myRandomValue = rand() % n; // returns a random number inclusive of the range 0..(n-1)
     
     return 0;
}

Since we are in the C++ forum lol, mistake by me. Make it ctime header and cstdlib :)

Chris

ty and tell this to my co member.... i'll let them handle this...lol

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.