Answer to Question #202531 in C for Prasanna

Question #202531

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.


1
Expert's answer
2021-06-03T05:00:07-0400
#include <stdio.h>
#include <stdlib.h>


void counter(char paragraph[],int* vowels,int* consonants,int* digits,int* symbols);


void main( void){
	char paragraph[1000];
	int vowels=0;
	int consonants=0;
	int digits=0;
	int symbols=0;


	printf("Enter the paragraph: ");
	gets(paragraph);
	counter(paragraph,&vowels,&consonants,&digits,&symbols);


	printf("The number of vowels: %d\n",vowels);
	printf("The number of consonants: %d\n",consonants);
	printf("The number of digits: %d\n",digits);
	printf("The number of symbols: %d\n\n",symbols);


	getch();
	getch();
}


void counter(char paragraph[],int* vowels,int* consonants,int* digits,int* symbols){
	int vowelsCounter=0;
	int consonantsCounter=0;
	int digitsCounter=0;
	int symbolsCounter=0;
	int i,j;
	for (i = 0; paragraph[i] != '\0'; ++i) {
		if (paragraph[i] == 'a' || paragraph[i] == 'e' || paragraph[i] == 'i' ||
			paragraph[i] == 'o' || paragraph[i] == 'u' || paragraph[i] == 'A' ||
			paragraph[i] == 'E' || paragraph[i] == 'I' || paragraph[i] == 'O' ||
			paragraph[i] == 'U') {
				vowelsCounter++;
		} else if ((paragraph[i] >= 'a' && paragraph[i] <= 'z') || (paragraph[i] >= 'A' && paragraph[i] <= 'Z')) {
			consonantsCounter++;
		} else if (paragraph[i] >= '0' && paragraph[i] <= '9') {
			digitsCounter++;
		} else{
			symbolsCounter++;
		}
	}
	*vowels=vowelsCounter;
	*consonants=consonantsCounter;
	*digits=digitsCounter;
	*symbols=symbolsCounter;
}




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