-2

I'm working on my school project and having an issue generating random numbers that are multiples of some other numbers(for example generating randoms that are multiples of 25) Can someone please help me with the codes?(C language)

Cipher
  • 1
  • 1
  • 4
    generate random numbers then multiply them by 25. Use this https://stackoverflow.com/questions/822323/how-to-generate-a-random-int-in-c – risingStark May 09 '21 at 15:29
  • You may want to read this: [How do I ask and answer homework questions?](https://meta.stackoverflow.com/q/334822/12149471) – Andreas Wenzel May 09 '21 at 15:32
  • Does this answer your question? [How to generate a random int in C?](https://stackoverflow.com/questions/822323/how-to-generate-a-random-int-in-c) – veryreverie May 09 '21 at 18:16

1 Answers1

2

Simply generate a random int between 1 and a max multiply-by number, and multiply this with your number (25 in your example)
code-

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

#define MULT_NUM 25

int main()
{
    srand(time(NULL));
    int r = rand() % 20 + 1;
    printf("The random multiple of %d is: %d\n", MULT_NUM, r * MULT_NUM);

    return 0;
}