what are the advantage of pointer variables? write a program
to count the number of vowels and consonants in a given string
Answers were Sorted based on User's Feedback
Answer / rama krishna sidhartha
The advantage of pointer variables is to reduce the memory
space of another variables.
I don't know how to write the program for counting the
vowels and consonants. If anybody knows please mail to
sidhartha_karyampudi@rediffmail.com
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / gaurav kumar
#include <stdio.h>
int vowel;
int consonant;
void check_vowel(char c)
{
if ( c != 'a' && c != 'e' && c != 'i' && c != 'o' && c != 'u' && c != 'A' && c != 'E' && c != 'I' && c != 'O' && c != 'U')
consonant ++;
else
vowel++;
return;
}
int main(void) {
char p[25];
char *ptr=p;
printf("Enter a string:");
scanf(" %[^\n]25s",p);
printf("%s\n",p);
printf("%c\n",*p);
while(*ptr != '\0')
{
if(*ptr != ' ')
check_vowel(*ptr);
ptr++;
}
printf("The number of vowels : %d and consonants : %d in %s \n",vowel,consonant,p);
return 0;
}
Please mail me if any compact solution?
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / 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 |
write a program to find the largest and second largest integer from an array
how to write palindrome program?
What is function what are the types of function?
How can I invoke another program from within a C program?
Define a structure to store the record of library. The record must consist of at least following fields: Title, Author, Edition, Price, Publisher, and Category. -Define functions authorSearch ( ), TitleSearch ( ) and CategorySearch ( ) to search a book with respect to author, title and category. [There can be more than one book, written by one author, in one category]
What is the difference between fread buffer() and fwrite buffer()?
Where are c variables stored in memory?
Write a c code segment using a for loop that calculates and prints the sum of the even integers from 2 to 30, inclusive?
What is the significance of c program algorithms?
Write a C program to check a number even or odd, without using any relational, arithmetic operator and any loops.
What is difference between && and & in c?
Why main function is special give two reasons?