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!

Homework Help: 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>

    main()
    {

    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.

    Thanks!
     
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

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