Thread: Lowercase letter frequency

  1. #1
    Registered User
    Join Date
    Nov 2010

    Lowercase letter frequency

    Hi guys, I need help with few things in this code.

    1.It doesn't show how often symbol appear in array;
    2.I'm not sure where to put the if function to check if its a lowercase letter and if its correct;
    3.What to write in the printf to show what lowercase letter is most frequent.

    #include <string.h>
    #include <stdio.h>
      int main()
      int i=0, max=0, freq=0, j;
      char array[]="AbcdFFaaAAchBaaamvxsdfGGbbb";
      char temp_symbol;
        for (i=0;i<=strlen(array);i++)
            for (j=0;j<strlen(array);j++)
                if (freq> max)
    printf("most frequent lowercase letter is   which repeats %d times", max );
    return 0;
    //  if(str[i] >= 97 && str[i] <= 122)

  2. #2
    Registered User
    Join Date
    Sep 2006
                if (freq> max)
    You record the max number of times a char is found, but you don't record the char that most popular.

    How about using a char variable for that, and adding a "mostCommonChar = temp_symbol" line of code into the mix, right here?

    There is a simpler way of doing all this, but your way is OK -- I like the logic here.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Invalid Output of Minimum and Maximum Value in Array
    By georgio777 in forum C Programming
    Replies: 10
    Last Post: 09-19-2009, 03:17 AM
  2. counting letter occurences in a string
    By pjr5043 in forum C++ Programming
    Replies: 35
    Last Post: 05-05-2008, 09:18 PM
  3. Advice requested, Code makes sense to me, not compiler
    By andrew.bolster in forum C Programming
    Replies: 53
    Last Post: 01-06-2008, 01:44 PM
  4. help using strings and mapping
    By trprince in forum C Programming
    Replies: 29
    Last Post: 12-01-2007, 04:01 PM
  5. letter frequency
    By knoxville in forum C Programming
    Replies: 15
    Last Post: 08-01-2006, 02:31 AM