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 difference between function overloading and operator overloading?
the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset
Give me the code of in-order recursive and non-recursive.
What is use of bit field?
What is null pointer in c?
How to write c functions that modify head pointer of a linked list?
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
What is the difference between array and pointer?
What is the difference between NULL and NUL?
What is difference between main and void main?
Explain what is the difference between the expression '++a' and 'a++'?
Write a code to generate divisors of an integer?
A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile
What is a c token and types of c tokens?
What is a pointer variable in c language?