Answer to Question #211737 in C for Pragadees

Question #211737

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 C program to count the number of vowels, consonants, digits and symbols using pointers.


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-29T02:02:01-0400
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
void getStat(char paragraphText[],int* vowels,int* consonants,int* digits,int* symbols,int* others);


void main( void){
	char paragraphText[5000];
	int vowels=0;
	int consonants=0;
	int digits=0;
	int symbols=0;
	int others=0;


	printf("Enter the paragraph text: ");
	gets(paragraphText);
	getStat(paragraphText,&vowels,&consonants,&digits,&symbols,&others);


	printf("No. of vowels: %d\n",vowels);
	printf("No. of consonants: %d\n",consonants);
	printf("No. of digits: %d\n",digits);
	printf("No. of symbols: %d\n",symbols);
	printf("Others: %d\n\n",others);


	getchar();
	getchar();
}




void getStat(char paragraphText[],int* vowels,int* consonants,int* digits,int* symbols,int* others){
	int i=0;
	while(paragraphText[i] != '\0') {
		if (tolower(paragraphText[i]) == 'a' || tolower(paragraphText[i]) == 'e' || tolower(paragraphText[i]) == 'i' ||
			tolower(paragraphText[i]) == 'o' || tolower(paragraphText[i]) == 'u') {
			(*vowels)++;
		} else if ((tolower(paragraphText[i]) >= 'a' && tolower(paragraphText[i]) <= 'z')) {
			(*consonants)++;
		} else if (paragraphText[i] >= '0' && paragraphText[i] <= '9') {
			(*digits)++;
		} else if (paragraphText[i] == '-'){
			(*symbols)++;
		}else{
			(*others)++;
		}
		i++;
	}
}







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