Find vowels,consonants,words,letters,alphabet form a given string array
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[100];
int b,d,e,i,l,p;
b=d=e=0;
printf("\nEnter the string : ");
gets(a);
l=strlen(a);
for(i=0;a[i]!='\0';i++)
{
if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U')
d++;
if (a[i]==' ')
e++;
}
p=l-(d+e);
b=l-e;
printf("\n\t No of vowels=%d \n",d);
printf("\n\t No of consonants=%d \n ",p);
printf("\n\t No of words=%d \n ",e+1);
printf("\n\t No of total letters=%d \n",l);
printf("\n\t No of alphabet=%d \n",b);
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char a[100];
int b,d,e,i,l,p;
b=d=e=0;
printf("\nEnter the string : ");
gets(a);
l=strlen(a);
for(i=0;a[i]!='\0';i++)
{
if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U')
d++;
if (a[i]==' ')
e++;
}
p=l-(d+e);
b=l-e;
printf("\n\t No of vowels=%d \n",d);
printf("\n\t No of consonants=%d \n ",p);
printf("\n\t No of words=%d \n ",e+1);
printf("\n\t No of total letters=%d \n",l);
printf("\n\t No of alphabet=%d \n",b);
}
Wap to print on screen.
ReplyDelete1
12
123
1234