I'm asked to write a program that takes as input a char value and
returns true if the character is uppercase; otherwise, it returns false..

so far I've made the definition of the function but I don't know how to get it's output on the screen through int main..could you help guys?thanks

bool uppercaseLetter(char ch)
{
    cout<<"Enter a character"<<endl;
    cin>>ch;
    if (isupper(ch))
    return true;
    else 

    return false;
}

Typically you wouldn't declare:

    cout<<"Enter a character"<<endl;
        cin>>ch;

inside the function ...that would be declared inside int main.

You could do the test and then cout if the condition is valid, but not quite sure what you want to do

what I want is how I'm gonna call this uppercaseLetter(char ch) in int main and cout the answer on the screen..I'm struck there.

okay it took some time but finally I've done it finally lol but I've some questions...When you return a value through a function, how will you cout in int main?

like:

int main(int a, int b)
{
return (a+b)
}

Looks like you need to study your notes on functions, passing values and returning values.

int main() is the MAIN entry point for any program so that stays the same. Leave it unchanged.

Here is an example:

#include <iostream>

using namespace std;

bool uppercaseLetter(char ch)
{
    if(isupper(ch))
      return true;
    else
      return false;
}

int main(int argc, char *argv[]) {

    char ch;

    cout << "Please enter the character";
    cin >> ch;

    if(uppercaseLetter(ch))
    {
        cout << "Yes, its uppercase";
    }else{
        cout << "No, it's not uppercase";
    }


}

Try not to use cout and cin within a function, instead, pass the character char to the function which you have done in your example.

I hope this helps.

This article has been dead for over six months. Start a new discussion instead.