Thursday, July 30, 2009

A random word program for c?

Im trying to write a program that will print 8 random words...they dont have to be real words.


The number of characters in the word must also be random...I have some syntax errors and I dont know why!!!!


%26lt;code snippet%26gt;


#define MinLetters 1


#define MaxLetters 9





char RandomWord(void);


main()


{


int n;


printf(" This program generates 8 random words.\n");


for(n = 1; n %26lt;= 8; n++)


{


printf("%c", RandomWord());


}


}





char RandomWord(void)


{


int i, j;





i = RandomInteger(int MinLetters, int MaxLetters);





for(j = 1; j %26lt;= i j++)


{


return (RandomInteger('A', 'Z');


}


printf("\n")


}





%26lt;/code snippet%26gt;





I have syntax errors in RandomWord before 'int' and before 'j'





Anybody feel like being a god???? lol


Thanks in advance guys...hopefully if I figure this language out I can answer some questions instead of asking

A random word program for c?
i = RandomInteger(int MinLetters, int MaxLetters);


needs to be changed to


i = RandomInteger(MinLetters, MaxLetters);





Also where is the seed value for random number generation?


No comments:

Post a Comment