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


Please Help Members By Posting Answers For Below Questions

Which node is more powerful and can handle local information processing or graphics processing?

832


how can I convert a string to a number?

604


what is the basis for selection of arrays or pointers as data structure in a program

3793


What are inbuilt functions in c?

564


in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none

608






What is pre-emptive data structure and explain it with example?

3216


write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1

3302


What do you mean by c?

597


Is there anything like an ifdef for typedefs?

708


Do you have any idea how to compare array with pointer in c?

611


What is printf () in c?

584


What is the maximum no. of arguments that can be given in a command line in C.?

674


In C programming, what command or code can be used to determine if a number of odd or even?

627


How do you search data in a data file using random access method?

844


What is typedef struct in c?

592