Answer to Question #204960 in C for Prasanna

Question #204960

In online journal system, the user has to give detail information about their abstract of the manual script before upload of source document. The abstract submitted by the author should not more than 300 words. The journal system uses program to count the number of vowels, consonants, digits and symbols in a given paragraph. Write a program to count the number of vowels, consonants, digits and symbols using pointers as reference to the function.



Runtime Input :


1=>see-programming.blogspot.com



Output :


No. of vowels: 8

No. of consonants: 17

No. of digits: 1

No. of symbols: 1

Others: 4


1
Expert's answer
2021-06-10T01:37:19-0400
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(int argc, char* argv[])
{
    char str[1000];
    int i,v,c,d,s,o;
    gets(str);


    v = 0;
    c = 0;
    d = 0;
    s = 0;
    o = 0;
    for (i = 0; i < strlen(str); i++)
    {
        if (str[i] >= ' ')
        {


            if (str[i] == '-')
                s++;
            else if (str[i] >= '0' && str[i] <= '9')
                d++;
            else if ((str[i] >= 'A' && str[i] <= 'Z') || (str[i] >= 'a' && str[i] <= 'z'))
            {
                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')
                    v++;
                else
                    c++;
            }
            else
                o++;
        }
    }


    printf("No.of vowels : %d\n",v);
    printf("No.of consonants :  %d\n",c);
    printf("No.of digits :  %d\n",d);
    printf("No.of symbols :  %d\n",s);
    printf("Others :  %d\n",o);


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS