#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    4
    Rep Power
    0

    C program ! can any one help


    Collect 10 alphabets find out how many valid english words can be made from these alphabets.
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,417
    Rep Power
    1871
    Read this first
    Make an effort, post what YOU can achieve, then post a meaningful question about some aspect of your program you're actually stuck on.

    Posting one sentence demands for homework on a plate will get you nowhere.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    4
    Rep Power
    0
    i just need a hint .... i tried it ... i got only random number gen,,,, dont knw for alphabets..
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,417
    Rep Power
    1871
    > i got only random number gen
    Well this would be a start.

    > dont knw for alphabets..
    Do you mean random letters?

    Perhaps
    Code:
    char alphabet[] = "abcde";
    int len = strlen(alphabet);
    char randomLetter = alphabet[ rand() % len ];
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    4
    Rep Power
    0
    yes... i need to generate random alphabets between a-z..
    and check how many valid words could be made of those randomly generated alphabets,and check with the dictionary , whether it is an valid word or not...
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    4
    Rep Power
    0
    when we execute it other time ... i am getting the same alphabet ....
    Code:
    ch = 'a' + rand() % ('z'-'a');
  12. #7
  13. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,417
    Rep Power
    1871
    Perhaps you should post a whole program, rather than just one line.

    You can make rand() return the same value, by not calling srand() at all, or by calling it too much.

    Or there are plenty of other mistakes we could waste time on guessing as well.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo