#include<stdio.h>
#include<stdlib.h>
int main() {
FILE * fp;
fp = fopen("lets.txt", "r");
int vowels = 0, constants = 0, spaces = 0, tabs = 0, specsym = 0, nolines = 1;
int c;
while ((c = fgetc(fp)) != EOF) {
if (c == 65 || c == 69 || c == 73 || c == 70 || c == 85 || c == 97 || c == 101 || c == 105 || c == 111 || c == 117) {
vowels++;
} else if (c == 32) {
spaces++;
} else if ((33 <= c <= 47) || (58 <= c <= 64) || (91 <= c <= 96) || (123 <= c <= 126)) {
specsym++;
} else if ((65 <= c <= 90) || (97 <= c <= 122)) {
constants++;
}
}
rewind(fp);
char c1;
while ((c1 = fgetc(fp)) != EOF) {
if (c1 == '\n') {
nolines++;
} else if (c1 == '\t') {
tabs++;
}
}
printf("The number of vowels are %d , constants %d, spaces %d, tabs %d, special symbols %d and lines %d", vowels, constants, spaces, tabs, specsym, nolines);
}
In the code below everything else is working fine other than the number of special symbols and characters, as you can see in the code they have completely different values to check for , but yet special symbols is counting characters too.If i put characters above it, it counts special symbols too.`