1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to randomize arrangement/order of output in C? (arrays)

  1. Aug 21, 2010 #1
    1. The problem statement, all variables and given/known data

    Hi I'm using C and I need to use arrays on this one, but I need to somehow randomize the output.

    2. Relevant equations

    for example an output "abcde" could also have an output "bcade" possible

    3. The attempt at a solution

    #include <stdio.h>


    char word[27] = "abcdefghijklmnopqrstuvwxyz";

    printf("The contents of word[] is %c%c%c\n", word[0], word[1], word[3]);


    the output of these one is "abc", but I want it to randomize it without rearranging the order of the output. In every run of the program, the order of the output should be diferent

    example for every run, the output would be "bac" or "cba" etc.

  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted

Similar Threads - randomize arrangement order Date
Fortran variable value changing randomly Sep 22, 2016
Random Walk w/o If-Statements Apr 17, 2015
How to do random arrangement of letters in C? Aug 17, 2010