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

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


সমস্যা

দেওয়া স্ট্রিং-এ কতগুলো স্বরবর্ণ (vowel) এবং ব্যঞ্জনবর্ণ (consonant) আছে তা গণনা করা।

লজিক

if(str[i]=='A'||'E'||'I'||'O'||'U'||'a'||'e'||'i'||'o'||'u')
    vowels++;
else
    consonants++;

উদাহরণ প্রোগ্রাম

/* Counting Vowels and Consonants in a String */
#include <stdio.h>
int main() {
    char str[100];
    int i, vowels, consonants;
    i = vowels = consonants = 0;
    printf("Enter any String\n : ");
    gets(str);
    while (str[i] != '\0') {
        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')
            vowels++;
        else
            consonants++;
        i++;
    }
    printf("vowels in this String = %d\n", vowels);
    printf("consonants in this String = %d", consonants);
    return 0;
}

আউটপুট

Enter any String: TutoriasPoint
vowels in this String = 6
consonants in this String = 7
  1. সি ভাষায় স্ট্রিং থেকে নম্বর এবং নম্বর থেকে স্ট্রিং কনভার্সন

  2. পাইথন প্রোগ্রাম: সেট ব্যবহার করে স্ট্রিং-এ স্বরবর্ণ (vowel) গণনা

  3. পাইথনে স্ট্রিং ও সংখ্যা তুলনা করার পদ্ধতি

  4. Python-এ স্ট্রিং-এ ভোয়েল (Vowel) সংখ্যা গণনা করা