what are the advantage of pointer variables? write a program
to count the number of vowels and consonants in a given string
Answer Posted / vadivelt
#include<stdio.h>
#include<conio.h>
CountVowCons(char *ptr, int *count);
int main()
{
char *ptr;
int count[2];
ptr = (char *)malloc(200);
printf("ENTER INPUT STRING\n");
ptr = gets(ptr);
CountVowCons(ptr, count);
printf("\nNO OF VOWELS:%d \nNO OF CONS: %d",count[0], count
[1]);
getch();
}
CountVowCons(char *ptr, int *count)
{
int Vowcount = 0, Conscount = 0;
while(*ptr != '\0')
{
if((*ptr == 'a') || (*ptr == 'A') || (*ptr == 'e') ||
(*ptr == 'E') || (*ptr == 'i') ||
(*ptr == 'I') || (*ptr == 'o') || (*ptr == 'O') ||
(*ptr == 'u') || (*ptr == 'U'))
{
Vowcount++;
}
else if((*ptr >= 65 && *ptr <= 90) ||
(*ptr >= 97 && *ptr <= 122))
{
Conscount++;
}
ptr++;
}
*count++ = Vowcount;
*count = Conscount;
count--;
}
| Is This Answer Correct ? | 1 Yes | 2 No |
Post New Answer View All Answers
What is call by reference in functions?
Define macros.
What do you understand by normalization of pointers?
Differentiate between Macro and ordinary definition.
what is ur strangth & weekness
What is the use of sizeof?
What's the total generic pointer type?
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
What is c method?
Explain how can I write functions that take a variable number of arguments?
I have a varargs function which accepts a float parameter?
Can the “if” function be used in comparing strings?
What are qualifiers and modifiers c?
What is signed and unsigned?
a c code by using memory allocation for add ,multiply of sprase matrixes