INDEX

COUNTING DIFFERENT CHARACTERS IN A STRING USING C PROGRAM

#include <stdio.h>
int isvowel(char chk);
int main(){
char text[1000], chk;
int count;
count = 0;
while((text[count] = getchar()) != '\n')
count++;
text[count] = '\0';
count = 0;
while ((chk = text[count]) != '\0'){
if (isvowel(chk)){
if((chk = text[++count]) && isvowel(chk)){
putchar(text[count -1]);
putchar(text[count]);
putchar('\n');
}
}
else
++count;
}
return 0;
}
int isvowel(char chk){
if(chk == 'a' || chk == 'e' || chk == 'i' || chk == 'o' || chk == 'u')
return 1;
return 0;
}

Alogrithm:
**

3. Write a c program to delete the all consonants from given string.

17 comments:

Anonymous said...

please give me the program to count the number of vowels in a given string

Anonymous said...

Pls explain the program to count the different type of characters in string.

Anonymous said...

please give me the program to count the number of letters in a given string

jasvir said...

write a program to accept any number up 6 digit and print in string. example input the number 1265 and output is one thousand sixty five

please give me the solution

yoga said...

#include
int main()
{
int num;
char str[100];
int i;
printf("\n Enter the number");
scanf("%d",&num);
sprintf(str,"%d",num);
//printf("%s",str);
for(i=0;str[i]!='\0';i++)
{

switch(str[i])
{
case '0':
printf("Zero\t");
break;
case '1':
printf("One\t");
break;
case '2':
printf("Two\t");
break;
case '3':
printf("Three\t");
break;
case '4':
printf("Four\t");
break;
case '5':
printf("Five\t");
break;
case '6':
printf("Six\t");
break;
case '7':
printf("Seven\t");
break;
case '8':
printf("Eight\t");
break;
case '9':
printf("Nine\t");
break;
default:
printf("wrong no");
break;
}
}
return 0;
}

Anonymous said...

void main()
{
int count_let=0,i;
char str{20];
clrscr();
printf("enter string:");
gets(str);
for(i=0;str[i]='\0';i++)
{
count_let++;
}
printf("no of letters are : %d",count_let);
getch();
}

Anonymous said...

dude by this we get the output as 1265=one two six five ..
??
and other one is where you are checking the number with string (a i mean translating ) ?
help me ...

Anonymous said...

void main()
{
int count_let=0,i;
char str{20];
clrscr();
printf("enter string:");
gets(str);
for(i=0;str[i]='\0';i++)
{
count_let++;
}
printf("no of letters are : %d",count_let);
getch();
}

mahesh said...

void main()
{
int count_let=0,count_vow=0;,i;
char str{20];
clrscr();
printf("enter string:");
gets(str);
for(i=0;str[i]='\0';i++)
{
count_let++;
if(str[i]='a'&&str[i]='e'&&str[i]='i'&&str[i]='0'&&str[i]='u')
{
count_vow++;
}
printf("no of letters are : %d",count_let);
printf("no of vowels are : %d",count_vow);

getch();
}

mahesh said...

void main()
{
int count_let=0,count_vow=0;,i;
char str[20];
clrscr();
printf("enter string:");
gets(str);
for(i=0;str[i]='\0';i++)
{
count_let++;
if(str[i]='a'&&str[i]='e'&&str[i]='i'&&str[i]='0'&&str[i]='u')
{
count_vow++;
}
printf("no of letters are : %d",count_let);
printf("no of vowels are : %d",count_vow);
}
getch();
}

Unknown said...

pls give prg to count frequency in string

Unknown said...

How these sprintf works.. can you explain?

Unknown said...
This comment has been removed by the author.
Unknown said...

#include

int main()
{ char str[10];
int letter=0,i;

printf("Enter a string\n");
scanf("%s",str);

for(i=0;str[i]!='\0';i++)
{
letter++;
}
printf("No of character is %d",letter);
return 0;
}

Unknown said...

#include

int main()
{ char str[10];
int letter=0,vowel=0,i;

printf("Enter a string\n");
scanf("%s",str);

for(i=0;str[i]!='\0';i++)
{
letter++;
if(str[i]=='a'||str[i]=='e'||str[i]=='o'||str[i]=='u'||str[i]=='i')
{
vowel++;
}
}
printf("No of character is %d",letter);
printf("No of vowel is %d",vowel);
return 0;
}

Unknown said...

Pls give me a program to enter some alphanumeric series, and then to convert characters in ascii, and numbers stay a numbers.

Unknown said...

Please can you tell me how to write a c program to sort a list of names in ascending order without using builtin functions