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


Please Help Members By Posting Answers For Below Questions

GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)

885


What is the difference between a string and an array?

948


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

2252


Without Computer networks, Computers will be half the use. Comment.

2070


What is the difference between exit() and _exit() function in c?

860


What is an operator?

867


Are pointers integer?

776


What is meant by high-order and low-order bytes?

861


What is the difference between Printf(..) and sprint(...) ?

1105


Wt are the Buses in C Language

2986


Why can't I perform arithmetic on a void* pointer?

848


please help me..... please codes and flowchart plz turbo c lang po yan.....please asap response... 3. Make an astrology program. The user types in his or her birthday (month, day, and year as integer), and the program responds with the user’s zodiac sign, horoscope, and other information related to it. If the user’s birth year falls into a leap year, your program should display an appropriate message for it. NOTES: Conditional Statements: it should be with graphics

3118


Explain what is the difference between far and near ?

873


What is the purpose of 'register' keyword?

909


Can 'this' pointer by used in the constructor?

840