im new to coding and currently working on pset2, readability, and I keep getting this error and can´t find a way to fix it.
#include <cs50.h>
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
int count_letters(string a, int b, int c);
int count_words(string a, int b, int c);
int count_sentences (string a, int b, int c);
float index_formula(int letters, int words, int sentences);
int main(void)
{
string text = get_string("Text: ");
int length = strlen(text);
int number_letters = 0;
int number_words = 0;
int number_sentences = 0;
count_letters(text, number_letters, length);
count_words(text, number_words, length);
count_sentences(text, number_sentences, length);
index_formula(count_letters, count_words, count_sentences);
printf("%f grade\n", index_formula);
}
int count_letters(string a, int b, int c)
{
for (int i = 0; i < c; i++)
{
if (isalpha(a[i]))
{
b++;
}
}
return b;
}
int count_words(string a, int b, int c)
{
for (int i = 0; i < c; i++)
{
if ((i == 0 && a[i] != ' ')
|| (i != c - 1 && a[i] == ' ' && a[i + 1] != ' '))
{
b++;
}
}
return b;
}
int count_sentences(string a , int b, int c)
{
for (int i = 0; i < c; i++)
{
if (a[i] == '.' || a[i] == '!' || a[i] == '?')
{
b++;
}
}
return b;
}
float index_formula(int letters, int words, int sentences)
{
float L = (letters / words) * 100;
float S = (sentences / words) * 100;
float index = (0.0588 * L) (- 0.296 * S) - 15.8;
return round(index);
}
Im pretty sure im doing it the wrong way, but what im trying to do is (being count_letters; count_words; count_sentences; and index_formula all functions) use the output of each function as an input for index_formula, and then print it, but i keep getting
error: incompatible pointer to integer conversion passing 'int (string, int, int)' (aka 'int (char *, int, int)') to parameter of type 'int' [-Werror,-Wint-conversion]
index_formula(count_letters, count_words, count_sentences);
Is there a way to fix it? Sorry if its a really dumb question, but i started programming a few weeks ago, and there is a lot I still dont get. Any help is really appeciated.