Wednesday, May 8, 2019

NUMBER OF VOWELS AND CONSTANT

  • Problem Description

    Count vowels and constants in a given string using pointers
  • Test Case 1

    Input (stdin)
    welcome

    Expected Output
    3 4
  • Test Case 2

    Input (stdin)
    hello

    Expected Output
    2 3
Solution

#include <stdio.h>

int main()
{
    char line[150];
    int i, vowels, consonants, digits, spaces;

    vowels =  consonants = digits = spaces = 0;
    scanf("%[^\n]", line);

    for(i=0; line[i]!='\0'; ++i)
    {
        if(line[i]=='a' || line[i]=='e' || line[i]=='i' ||
           line[i]=='o' || line[i]=='u' || line[i]=='A' ||
           line[i]=='E' || line[i]=='I' || line[i]=='O' ||
           line[i]=='U')
        {
            ++vowels;
        }
        else if((line[i]>='a'&& line[i]<='z') || (line[i]>='A'&& line[i]<='Z'))
        {
            ++consonants;
        }
        else if(line[i]>='0' && line[i]<='9')
        {
            ++digits;
        }
        else if (line[i]==' ')
        {
            ++spaces;
        }
    }

    printf("%d",vowels);
    printf(" %d",consonants);

    return 0;
}

1 comment:

  1. How to Get Online Pokies with Pokies - Casinoland.jp ボンズ カジノ ボンズ カジノ 카지노사이트 카지노사이트 betway login betway login 메리트 카지노 쿠폰 메리트 카지노 쿠폰 クイーンカジノ クイーンカジノ dafabet dafabet bk8 bk8 154 바카라 롤링 - Bienvenue Casino

    ReplyDelete

Parity

Problem Description Ram and Sita playing the parity game. Two types of parity are there. One is odd parity and next is even parity. Ram will...