Answer to Question #210037 in C for Kanan

Question #210037

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-23T17:06:30-0400
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>


void countVowelsConsonantsDigitsSymbols(char paragraph[],int* numberVowels,int* numberConsonants,int* numberDigits,int* numberSymbols,int* numberOthers){
	int i,j;
	for (i = 0; paragraph[i] != '\0'; ++i) {
		if (tolower(paragraph[i]) == 'a' || 
			tolower(paragraph[i]) == 'e' || 
			tolower(paragraph[i]) == 'i' ||
			tolower(paragraph[i]) == 'o' || 
			tolower(paragraph[i]) == 'u') {
				*numberVowels=*numberVowels+1;
		} else if ((tolower(paragraph[i]) >= 'a' && tolower(paragraph[i]) <= 'z')) {
				*numberConsonants=	*numberConsonants+1;
		} else if (paragraph[i] >= '0' && paragraph[i] <= '9') {
			*numberDigits=*numberDigits+1;
		} else if (paragraph[i] == '-'){
			*numberSymbols=*numberSymbols+1;
		}else{
			*numberOthers=*numberOthers+1;
		}
	}
}


void main( void){
	char paragraph[10000];
	int numberVowels=0;
	int numberConsonants=0;
	int numberDigits=0;
	int numberSymbols=0;
	int numberOthers=0;


	printf("Enter the paragraph: ");
	gets(paragraph);
	countVowelsConsonantsDigitsSymbols(paragraph,&numberVowels,&numberConsonants,&numberDigits,&numberSymbols,&numberOthers);


	printf("No. of vowels: %d\n",numberVowels);
	printf("No. of consonants: %d\n",numberConsonants);
	printf("No. of digits: %d\n",numberDigits);
	printf("No. of symbols: %d\n",numberSymbols);
	printf("Others: %d\n\n",numberOthers);


	getchar();
	getchar();
}




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