Code:
#include <stdio.h>
#include <string.h>
int
main (void)
{
int v, vowels, w, words, s, sentences;
double score;
char text[1500];
FILE *input;
input = fopen("beatles.txt", "r");
fgets (text, sizeof(text), input);
/* to count vowels*/
for(v=0; text[v] != '\0'; v++)
{switch(text[v])
{case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
vowels++;
}
}
printf("vowels:%d", &vowels);
/* to count words */
for(w=0; text[w] != '\0'; w++)
{switch(text[w])
{case ' ':
words++;
}
}
printf("words: %d", &words);
/* to count for sentences */
for(s=0; text[s] != '\0'; s++)
{switch(text[s])
{case '.':
case '!':
case '?':
case ':':
sentences++;
}
}
printf("sentences:%d", &sentences);
/* to calculate FRES score */
score = 206.835 - ((1.015) * (words/sentences)) - ((84.6) * (vowels/words));
if (score > 70)
printf ("A elementary education \n");
else
if (score >=50 || score<=70)
printf ("secondary education \n");
else
if (score>=20 || score<=50)
printf ("College \n");
else
if (score < 20)
printf ("expert \n");
return(0);
}