#include<conio.h>
#include<stdio.h>
void main()
{
char s[100];
int i,v=0,con=0,w=1,lett=0,sen=0;
clrscr();
printf("Enter the value of string:\n");
gets(s);
for(i=0;s[i]!='\0';i++)
{
if(s[i]==' '||s[i]==',')
{
w++;
}
else if (s[i]=='.'||s[i]=='?'||s[i]=='!')
{
sen++;
}
else if((s[i]>=65)&&(s[i]<=90)||(s[i]>=97)&&(s[i]<=122))
{
lett++;
switch(s[i])
{
case 'A':
case 'a':
case 'E':
case 'e':
case 'I':
case 'i':
case 'O':
case 'o':
case 'U':
case 'u':
v++;
break;
default:
con++;
break;
}
}
}
printf("Number of letters: %d\n",lett);
printf("Number of vowels: %d\n",v);
printf("Number of consonants: %d\n",con);
printf("Number of words: %d\n",w);
printf("Number of sentences: %d\n",sen);
getch();
}
#include<stdio.h>
void main()
{
char s[100];
int i,v=0,con=0,w=1,lett=0,sen=0;
clrscr();
printf("Enter the value of string:\n");
gets(s);
for(i=0;s[i]!='\0';i++)
{
if(s[i]==' '||s[i]==',')
{
w++;
}
else if (s[i]=='.'||s[i]=='?'||s[i]=='!')
{
sen++;
}
else if((s[i]>=65)&&(s[i]<=90)||(s[i]>=97)&&(s[i]<=122))
{
lett++;
switch(s[i])
{
case 'A':
case 'a':
case 'E':
case 'e':
case 'I':
case 'i':
case 'O':
case 'o':
case 'U':
case 'u':
v++;
break;
default:
con++;
break;
}
}
}
printf("Number of letters: %d\n",lett);
printf("Number of vowels: %d\n",v);
printf("Number of consonants: %d\n",con);
printf("Number of words: %d\n",w);
printf("Number of sentences: %d\n",sen);
getch();
}
0 comments:
Post a Comment