How to print characters in array in random order???
Hello, so I'm kind of stuck. I am writing a C code which allows a user to enter their student number, then choose whether they want their student number written in the forwards direction, backwards or in random order. I am unsure how to randomize the characters entered into the array so I can then print them out in random order. Wonder if anyone can help? Here is how far I got: #include <stdio.h> #include <stdlib.h> #include<string.h> int main(void) { char fbr; int i; char name[9]; // char string as an array of characters printf("Please enter student number: "); //prompt user to enter student number scanf("%s", name); //accept input from user getchar(); // required to avoid return key being recognised as a character printf("\nYour student number has been entered. Please type f to print in forward direction, b to print backwards or r for random: \n\n"); scanf("%c", &fbr); if (fbr == 'f') //Print student number in the Forward Direction for(i=0; i<9; i++) { printf("%c",name[i]); } else if (fbr == 'b') // Print student number in the Reverse Direction for(i=8; i>=0; i--) { printf("%c",name[i]); } else if (fbr == 'r') { // Print student number Randomly } else { printf("\n\n hmmmmm \U0001F914 looks like you have entered an invalid option, please restart program and try again;"); } return 0; } \\end of code Thanks