Skip to content

Instantly share code, notes, and snippets.

@AnujJha-stack
Created January 7, 2020 08:17
Show Gist options
  • Save AnujJha-stack/ec7dc1f41c77fb65fbfa8fb849a8e501 to your computer and use it in GitHub Desktop.
Save AnujJha-stack/ec7dc1f41c77fb65fbfa8fb849a8e501 to your computer and use it in GitHub Desktop.
POC
// coded by Anuj Jha
//
#include <stdio.h>
#include<ctype.h>
int main() {
FILE *fp;
char vowels[] = {'a','e','i','o','u'};
char alphabets[] = {'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z'};
char digit[] = {'0','1','2','3','4','5','6','7','8','9'};
char spSymbol[] = {'#','!','@','$','^','&','*'};
int count_vowel=0,count_alphabet=0,count_digit=0,count_sp_symbol = 0;
fp = fopen("/home/evil/CLionProjects/files/1.txt","r");
while(1)
{
char ch=fgetc(fp);
if(ch==EOF)
{
break;
}
else
{
for(int i = 0; i < sizeof(vowels) ;i++)
{
if(ch == vowels[i])
{
printf("%c is vowel.\n",vowels[i]);
count_vowel++;
break;
}
}
for(int i = 0; i < sizeof(alphabets) ;i++)
{
if(ch == alphabets[i])
{
printf("%c is Consonants.\n",ch);
count_alphabet++;
break;
}
}
for(int i = 0; i < sizeof(digit) ;i++)
{
if(ch == digit[i])
{
printf("%c is digit.\n",digit[i]);
count_digit++;
break;
}
}
for(int i = 0; i < sizeof(spSymbol) ;i++)
{
if(ch == spSymbol[i])
{
printf("%c is special Symbol.\n",spSymbol[i]);
count_sp_symbol++;
break;
}
}
}
}
printf("Number of vowels: %d\n",count_vowel);
printf("Number of Consonant: %d\n",count_alphabet);
printf("Number of Digit: %d\n",count_digit);
printf("Number of Special Symbol: %d\n",count_sp_symbol);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment