what are the advantage of pointer variables? write a program
to count the number of vowels and consonants in a given string
Answer Posted / gaurav kumar
#include <stdio.h>
int vowel;
int consonant;
void check_vowel(char c)
{
if ( c != 'a' && c != 'e' && c != 'i' && c != 'o' && c != 'u' && c != 'A' && c != 'E' && c != 'I' && c != 'O' && c != 'U')
consonant ++;
else
vowel++;
return;
}
int main(void) {
char p[25];
char *ptr=p;
printf("Enter a string:");
scanf(" %[^\n]25s",p);
printf("%s\n",p);
printf("%c\n",*p);
while(*ptr != '\0')
{
if(*ptr != ' ')
check_vowel(*ptr);
ptr++;
}
printf("The number of vowels : %d and consonants : %d in %s \n",vowel,consonant,p);
return 0;
}
Please mail me if any compact solution?
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain two-dimensional array.
What is a newline escape sequence?
What is a c token and types of c tokens?
What is oops c?
p*=(++q)++*--p when p=q=1 while(q<=6)
What's the best way of making my program efficient?
What is 02d in c?
please give me some tips for the placement in the TCS.
Differentiate between a structure and a union.
What is variable in c example?
What is the best way to comment out a section of code that contains comments?
Is it possible to pass an entire structure to functions?
How can you find the exact size of a data type in c?
How many loops are there in c?
How can I avoid the abort, retry, fail messages?