Join the social network of Tech Nerds, increase skill rank, get work, manage projects...

• # Program to count number of vowels and consonants in a string

• 0
• 0
• 0
• 0
• 0
• 0
• 0
• 0
• 509
Comment on it

Counting number of vowels,consonants and digits in a string:

In this program we are counting how many vowels ,consonants and digits are in the string which will be entered by the user. After user inputs a string , string will be iterated from 0th index to last index means until it not terminate with null.

• The variable vowel will count the number of vowels and variable con will count the number of consonants in the string.
• Digit variable will count the number of digits in a string.

```#include<string.h>
void main()
{
char str[10];
int b,digit,vowel,e,i,l,con;
b=digit=vowel=e=0;

printf("\n\t Enter any string :");
scanf("%s",str);

for(i=0;str[i]!='\0';i++)
{
if((str[i]>=65&&str[i]<=90||str[i]>=97&&str[i]<=122))
b++;
if(str[i]>=48&&str[i]<=57)
digit++; // digit variable will be incremented if digits found
if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'||str[i]=='A'||str[i]=='E'||str[i]=='I'||str[i]=='O'||str[i]=='U')
vowel++; // vowel variable will be incremented if vowels found
if (str[i]==' ')
e++;
}
con=b-vowel; // it will count the number of consonants in the string

printf("\n\t No of vowels=%d \n",vowel);
printf("\n\t No of consonants=%d \n ",con);
printf("\n\t No of digits=%d \n",digit);

}
```

## 0 Comment(s)

OR
OR
Register

OR
Fill out the form below and instructions to reset your password will be emailed to you:

• Hire
• Post Projects

### Post Projects

• All at 0 Cost ....
• Post Tech Job
• Select Best Bidder
• Track the Project
• Approve Work and Pay safely
• Browse Nerds
• Work
• Find Projects Find Projects
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
• Manage
• Company Company

### Manage Company

• All at 0 Cost ....
• Manage Company and Employee Profiles
• Company wide Employee Productivity Reports
• Knowledge Sharing and Collaboration Tools
• Get Sales Lead and Bid for Tech Projects
• Send Invoices and Receive Payment Safely
• Learn
• Nerd Digest Nerd Digest
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General
• Tech Q & A Tech Q & A
• UI Design and UX
• Software Engineering
View more...
View less...
• Marketing
• General