Pick random element: Difference between revisions
Content deleted Content added
m Added C implementation |
|||
Line 1:
{{draft task|Basic language learning}}
How does one pick a random element from a list?
=={{header|C}}==
<lang C>#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
char array[] = { 'a', 'b', 'c' };
srand( time( 0 ) );
printf( "%c\n", array[ rand() % 3 ] );
return 0;
}</lang>
=={{header|Haskell}}==
|