I am trying to find random numbers from 1 to 5. I made this code-
#include <stdio.h>
#include <stdlib.h>
int main(){
  int r;
  r = rand() % 5 + 1;
  printf("%d ", r);
    
  
  switch (r){
    case 1:
      printf("1\n");
      break;
    case 2:
      printf("2\n");
      break;
    case 3:
      printf("3\n");
      break;
    case 4:
      printf("4\n");
      break;
    case 5:
      printf("5\n");
      break;
  }
  return 0;
}
For some reason, for both outputs, for the first print, and the switch, I just get the output "4 4." How do I get it so that each time it's a different number in that list? Do I need to loop it?
