Program:
#include<stdio.h>
int main(){
char string[100];
int i,vowel=0,consonant=0;
printf("Enter the String:");
scanf("%s",string);
printf("\nString-> %s\n",string);
for(i=0;string[i] != '\0';i++){
if(string[i]=='A'||string[i]=='E'||string[i]=='I'||string[i]=='O'||string[i]=='U'||string[i]=='a'||string[i]=='e'||string[i]=='i'||string[i]=='o'||string[i]=='u'){
vowel++;
}
else{
consonant++;
}
}
printf("Length Of the String= %d\n",i); //i represents the No. of time loops get Executed
printf("\t-->> N0. of Vowels= %d\n",vowel);
printf("\t-->> N0. of Consonants= %d\n",consonant); // U can also write i-vowel
}
int main(){
char string[100];
int i,vowel=0,consonant=0;
printf("Enter the String:");
scanf("%s",string);
printf("\nString-> %s\n",string);
for(i=0;string[i] != '\0';i++){
if(string[i]=='A'||string[i]=='E'||string[i]=='I'||string[i]=='O'||string[i]=='U'||string[i]=='a'||string[i]=='e'||string[i]=='i'||string[i]=='o'||string[i]=='u'){
vowel++;
}
else{
consonant++;
}
}
printf("Length Of the String= %d\n",i); //i represents the No. of time loops get Executed
printf("\t-->> N0. of Vowels= %d\n",vowel);
printf("\t-->> N0. of Consonants= %d\n",consonant); // U can also write i-vowel
}
Expected O/P:
Enter the String:India
String-> India
Length Of the String= 5
-->> N0. of Vowels= 3
-->> N0. of Consonants= 2
0 Comments
Post a Comment