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
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)
What is the difference between a string and an array?
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.
Without Computer networks, Computers will be half the use. Comment.
What is the difference between exit() and _exit() function in c?
What is an operator?
Are pointers integer?
What is meant by high-order and low-order bytes?
What is the difference between Printf(..) and sprint(...) ?
Wt are the Buses in C Language
Why can't I perform arithmetic on a void* pointer?
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
Explain what is the difference between far and near ?
What is the purpose of 'register' keyword?
Can 'this' pointer by used in the constructor?