so i find the period or whatever the sentence ends in. Then I create a substring from that and delete the part which contains the end character. Then i keep count of it.

Not sure why you want to delete anything, but counting lines by counting periods is one way to do it yes.
Keep in mind that periods are also used for other purposes like abbreviations and stuff like this >...

can someone check if this makes sense to find # of sentences. i think it does.

#include<iostream>

using namespace std;
int main()
{
string passage;
int space=0;
int sentence=0;
int word=0;
int character;
cout<<"enter the passage to find out readability index";
getline(cin,passage);
    for (int  i = 0; i < passage.length(); i++)
    {
        //number of words
        if (isspace(passage[i]) )
        {
            space++;
        }
        word=space+1;
        //number of sentences
        if(character=(passage.find('.')))
        {
            passage.substr(0,character);
            passage.erase(0,character+1);
            sentence++;
            cout<<"should print out multiple";
        }
        
    }
    cout<<"the sentence is"<<sentence;
    //cin.get();
    return 0;
}

why doesn't the or operator work here? when i try to include semicolon.

if(character=(passage.find('.')))

I was just going through your code and found out this,

You are assigning a value to the variable character instead of checking.

it should actually be

if(character[b]==[b](passage.find('.')))
#include<iostream>

using namespace std;
int main()
{
string passage;
int space=0;
int sentence=0;
int word=0;
int character;
cout<<"enter the passage to find out readability index";
getline(cin,passage);
    for (int  i = 0; i < passage.length(); i++)
    {
        //number of words
        if (isspace(passage[i]) )
        {        
            space++;
        }
        word=space+1;
        //number of sentences
        if(character[i]==(passage.find('.')))
        {
            passage.erase(0,character+1);
            sentence++;
        }
        
    }
    cout<<"the sentence is"<<sentence;
    cin.get();
    return 0;
}

it still gives me error. invalid type int[int]

character is of type integer. and it is not an array .

I wish to know what you are trying to achieve in the following code
That way it would be easier to help..

if(character[i]==(passage.find('.')))
        {
            passage.erase(0,character+1);
            sentence++;
        }

how do i find out # of sentences if they contain a :, :, ! or ?

if(character[i]==(passage.find('.')))
        {
            passage.erase(0,character+1);
            sentence++;
        }

Replace this with something like

if(issentence(passage[i])==true)
        {
            sentence++;
        }

After that write down a function

bool issentence(char);

Which returns true if the character is a '.' or ',' or '!' or '?'

I guess that's what you want right :)

so i would need to make a method to find the issentence?

You should be using this function:

http://www.cplusplus.com/reference/string/string/find_first_of/

string delimeters = ".?!";
string passage = "ab.cd.ef!gh?ij.";
int pos = passage.find_first_of (delimiters);

It'll find the first incidence of '.', '?', or '!', which will be index 2. Then erase the first 3 characters using erase, as you've been doing, and go through it again.

oh okay i will give that a try.

it seems to work thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.