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

Explain what is gets() function?

639


When we use void main and int main?

593


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)

689


Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor

2992


What is struct node in c?

625






What are different storage class specifiers in c?

623


What is scanf_s in c?

638


What are the different types of linkage exist in c?

617


Why is %d used in c?

569


Explain how do you search data in a data file using random access method?

702


What are the general description for loop statement and available loop types in c?

691


Can we use any name in place of argv and argc as command line arguments?

615


Can i use “int” data type to store the value 32768? Why?

760


How can I check whether a file exists? I want to warn the user if a requested input file is missing.

661


What is a structure in c language. how to initialise a structure in c?

613