Z
Z
Zhenia Bel2021-11-28 02:06:29
C++ / C#
Zhenia Bel, 2021-11-28 02:06:29

How to generate an array with multiples of 7 in C?

How to generate an array with multiples of 7 in C?

here is a sample code

int main() {
  srand(time(0));
  int arr[N],a,b;
  

  printf("A: "); scanf_s("%d", &a);
  printf("B: "); scanf_s("%d", &b);
  for (int i = 0; i < N; i++) {
    arr[i] = a + rand() % b *7;
    printf("%4d", arr[i]);
  }

  

}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2021-11-28
@Rsa97

Generate random numbers.
Multiply them by 7.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question