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
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?
Why do we use static in c?
What is a sequential access file?
Explain how do you use a pointer to a function?
Explain what is the advantage of a random access file?
Why is c known as a mother language?
How can type-insensitive macros be created?
Is it possible to use curly brackets ({}) to enclose single line code in c program?
Why doesnt this code work?
What is difference between static and global variable in c?
What are the characteristics of arrays in c?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
When is a void pointer used?
What is an expression?