Declaring a variable as a letter or word

Hello everyone. I'm having this problem which I just cannot seem to find the answer to anywhere. I need to declare a variable as a letter or word using an if-else statement. For example, if a numeric value is greater than ten, then I need the variable to be declared as "Yes.", and if the value is less than or equal to ten, I need the variable to be declared as "No.". Unfortunately, I cannot just use "cout <<". Any help would be greatly appreciated!
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
    int Value = 12;
    std::string Words;
    // You can do this:
    Value <= 10 ? Words = "Ten or less" : Words = "More than ten";
    // .. or this:
    if(Value <= 10) {
        Words = "Ten or less";
    } else {
        Words = "More than ten";
    }
    // they're both the same.
    cout << Words;

?
Last edited on
It is not a declaration. It is an assignment.


1
2
3
4
int x = 10;
std::string s;

s = ( 10 < x ) ? "Yes" : "No";
Topic archived. No new replies allowed.