For homework I am tasked with making a random generator that gives a different outcome whenever it is executed using function prototypes, switches, and enum. I tried everything I could, but the outcomes I got was after executing the program the result would just repeat itself a few times before going to a different result it even would bring me back to bash prompt.
What am I doing wrong?
I compiled it using GCC if that helps.
Code:
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
enum meme {YEE, WAE, VERY, HARAMBE};
int dankestmemes(void); // function prototype
int main(void) {
srand(time(NULL)); // randomize random generator using current time
//int randomNumber = rand() % 5;
int memes;
enum meme dankMeme; // can contain YEE, WAE, VERY, HARAMBE
int dank = dankestmemes(); // When program first executes
switch((dank + randomNumber) % 5){ //puts you in a meme tribe
case 1:
dankMeme = YEE;
printf("Welcome to the tribe of the Yee Dinosaur. ");
printf("You are very wise for choosing this tribe\n");
break;
case 2:
dankMeme = WAE;
printf("You have found da wae to da Ugandan Knuckle ");
printf(" Tribe my brutha. \n");
printf("Now let us look for our queen.\n");
break;
case 3:
dankMeme = VERY;
printf("MUCH WOW. VERY AMAZE YOU JOIN DOGE TRIBE!\n");
break;
case 4:
dankMeme = HARAMBE;
printf("You have been blessed with the precense of Harambe\n ");
printf("in the Harambe Tribe, here we honor the greatest thing \n");
printf("that sacrificed it's life trying to protect a child. \n");
printf("Harambe is gone, but will never be forgotten!\n");
break;
}
}
int dankestmemes(void){
return (rand() % 6) + (rand() % 6) + 2; // Randomizes outcome
}