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
Explain what is gets() function?
When we use void main and int main?
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)
Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor
What is struct node in c?
What are different storage class specifiers in c?
What is scanf_s in c?
What are the different types of linkage exist in c?
Why is %d used in c?
Explain how do you search data in a data file using random access method?
What are the general description for loop statement and available loop types in c?
Can we use any name in place of argv and argc as command line arguments?
Can i use “int” data type to store the value 32768? Why?
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
What is a structure in c language. how to initialise a structure in c?