“Guess the Number between 1-1000 game” in C – How do I make it so that you can replay it without manually running it again?

So I have my first C program where you guess the number between 1 and 1000. It plays well enough, but when I press Y or N to have the user replay the game after winning, it just ends the program. I want n to kill the program, y to restart it all over again. How do I accomplish this? Here’s the program.

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

int main(void)

    int random_num = 0;
    int guessed_num = 0;
    int counter = 0;
    char selection = 'y';
    random_num = rand() % 1000 + 1;

    printf("I have a number between 1 and 1000, can you guess my number??? ");

    while (selection == 'y')

        scanf_s("%d", &guessed_num);

        if (guessed_num == random_num)
            printf("You guessed correctly in %d tries! Congratulations! Guess again? (y or n)n", counter);
            scanf_s("%d", &selection);

        if (guessed_num < random_num)
            printf("Your guess is too low. Guess again. ");

        if (guessed_num > random_num)
            printf("Your guess is too high. Guess again. ");


    return 0;