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
What is the explanation for cyclic nature of data types in c?
I need previous papers of CSC.......plz help out by posting them.......
Explain the use of 'auto' keyword
What is the correct declaration of main?
What is the difference between union and structure in c?
If null and 0 are equivalent as null pointer constants, which should I use?
struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer
What are structures and unions? State differencves between them.
In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.
What is use of #include in c?
What is string concatenation in c?
write a program to copy the string using switch case?
Explain pointer. What are function pointers in C?
What are the types of data types and explain?
Can a variable be both static and volatile in c?