Question
I'm having trouble getting my program to output this statement Enter a sentence: Test! There are 5 total characters. There are 1 vowel. There are
I'm having trouble getting my program to output this statement
Enter a sentence: Test!
There are 5 total characters. There are 1 vowel. There are 1 UPPERCASE letters. There are 3 lowercase letters. There are 1 other characters.
Here's my code:
#include
#include
#include
int main() {
char str[100];
int i;
int vowels=0;
int UC;
int LC;
int Others;
int c;
printf("Enter a sentence: ");
gets(s);
LC=countLC(&s);
UC=countUC(&s);
Others=countOthers(&s);
printf("There are %d total characters. ", ;
for(i=0; i if(isVowel(str[i])) vowels++; } printf("There are %d vowels. ", vowels); printf("There are %d UPPERCASE letters. ", UC); printf("There are %d lowercase letters. ", LC); printf("There are %d other characters. ", Others); return(0); } bool isVowel(char ch){ if (ch =='a' || ch=='e'|| ch=='i' || ch== 'o' || ch=='u' || ch =='A' || ch=='E'|| ch=='I' || ch== 'O' || ch=='U') return true; else return false; } int countUC(char *str){ int count=0, i=0; for(i=0; i if(str[i]>=65 && str[i]<=90) count++; } return count; } int countLC(char *str){ int count=0, i=0; for(i=0; i if(str[i]>=97 && str[i]<=122) count++; } return count++; } int countOthers(char *str){ return countOthers; } int countVowel(char* str) { char*s= str; int vowel=0; while(*s!='\0') { if(isVowel(*s)) { vowel++; } s++; } return vowel; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started