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
Why do we use null pointer?
What does sizeof int return?
Add Two Numbers Without Using the Addition Operator
Explain what is the most efficient way to store flag values?
Can you explain the four storage classes in C?
What is far pointer in c?
In a byte, what is the maximum decimal number that you can accommodate?
What is stack in c?
What is a pragma?
What is the c value paradox and how is it explained?
What are compound statements?
Can we use any name in place of argv and argc as command line arguments?
In c programming language, how many parameters can be passed to a function ?
How can I read in an object file and jump to locations in it?
What is a pointer in c plus plus?