কম্পিউটার টিউটোরিয়াল

শব্দ, স্বরবর্ণ এবং প্রতিটি ক্যারেক্টারের ফ্রিকোয়েন্সি গণনা


একটি স্ট্রিং ইনপুট নিয়ে মোট শব্দ, স্বরবর্ণ এবং ইউজার দ্বারা ইনপুট করা একটি ক্যারেক্টারের ফ্রিকোয়েন্সি বের করতে হবে।

Input : enter s string : I love my MOM Enter a charcter of which you want to find a frequency: M Total frequency of M : 2 Total number of vowels : 4 Total number of words : 4

অ্যালগরিদম

START Step 1 Declare array of string, ch, i, freq to 0, vow to 0, word to 0 Step 2 Input a string and a character ch Step 3 Loop for from i to 0 and str[i]!='\o' and ++i Step 3.1 IF statement for ch==str[i]    Post incrementing freq    Step 3.2 End If    Step 3.3 IF statement    str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'||str[i]=='A'||str[i]=='E'||str[i]=='I'||str[i]=='O'||str[i]=='U'       Post incrementing vow    Step 3.4 End If    Step 3.5 IF statement str[i]=' '       Post incrementing word    Step 3.6 End If Step 4 End For loop STOP

উদাহরণ

#include  int main() {    char str[1000], ch;    int i, freq=0, vow=0, word=0;    printf("Enter a string of your choice: ");    gets(str);    printf("Enter a character of which you want to find the frequency: ");    scanf("%c",&ch);    for(i = 0; str[i] != '\0'; ++i){       if(ch == str[i]) //to find the frequency of a character {          ++freq;       }       if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'||str[i]=='A'||str[i]=='E'||str[i]=='I'||str[i]=='O'||str[i]=='U') {          ++vow; //to find the number of vowels       }       if (str[i] == ' ') {          word++; //to find the number of words       }    }    printf("Frequency of %c = %d", ch, freq);    printf("\ntotal number of vowels in a string are %d " ,vow );    printf("\ntotal number of words in a string are %d " ,word+1 );    return 0; }

আউটপুট

যদি উপরের প্রোগ্রামটি রান করি তবে নিচের আউটপুট জেনারেট হবে।

Enter a string of your choice: I love PrograMMIng Enter a character of which you want to find the frequency: M Frequency of M = 2 total number of vowels in a string are 6 total number of words in a string are 3

  1. সি ভাষায় স্ট্রিং থেকে নম্বর এবং নম্বর থেকে স্ট্রিং কনভার্সন

  2. সি প্রোগ্রাম দিয়ে স্ট্রিংয়ের প্রতিটি ক্যারেক্টার ফ্রিকোয়েন্সি কাউন্ট করা

  3. সি ভাষায় স্ট্রিং-এ স্বরবর্ণ ও ব্যঞ্জনবর্ণ গণনা করা

  4. C প্রোগ্রামিং-এ স olid এবং হোলো রোম্বাস প্যাটার্ন প্রিন্ট করা