Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Finding frequency of a character in a string

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 486
    Comment on it

    This program is all about finding how many times a character comes in a string. In the program there is a count variable which will be incremented if the same character appears again and then that count variable will be printed.

      #include <stdio.h>
        int main(){
           char c[1000],char;
           int i,count=0;
           printf("Enter any string ");
           printf("Enter any character whose frequency u want to find: ");
                // comparing string with the character whose frequency we want to find.
               // increment the count variable if the same character repeated.
           printf("Frequency of %c = %d", char, count);   // printing the frequency of the character.
           return 0;


    Enter a string: Welcome to Findnerd.
    Enter a character to find frequency: e
    Frequency of e = 3

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: