I am currently working through the CS50 course and ran into an issue. I am using the CS50 IDE and for some reason I can't seem to do basic math operations... I'm not sure why this is but the code at the bottom just will not calculate the index. And the avgsentences and avgword just keeps coming out as the original sentences and word amounts.
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
int main (void)
{
string text;
text = get_string("Text: ");
//Count the number of letters, words, and sentences in the text
int letters;
int word = 1;
int sentences = 0;
for (int i = 0; i < strlen(text); i++)
{
if(isalpha(text[i]))
{
letters = letters + 1;
}
else if(text[i]==' ' || text[i]=='\0')
{
word = word + 1;
}
else if(text[i] == '.' || text[i] == '!' || text[i] == '?')
{
sentences = sentences + 1;
}
}
//Average per 100 words
float avgletters = (100 / word) * letters;
float avgsentences = (100 / word) * sentences;
double index = 0.0588 * avgletters * 0.296 - avgsentences - 15.8;
printf("Letter(s): %f\n", avgletters);
printf("Word(s): %i\n", word);
printf("Sentences: %f\n", avgsentences);
printf("Index: %f\n", index);
}```