-5

How do you check if bacon is true, and what is the command to print or produce a readable output?

int main() {
    bool bacon = true;
    if ("bacon") == true;
    print("this worked?");
}
PEHLAJ
  • 9,980
  • 9
  • 41
  • 53
KiraCChan
  • 11
  • 1
  • 4
  • 4
    I'm voting to close this question as off-topic because it is basic knowledge covered by any C++ learning material. Stack Overflow is a second line resource, after you've consulted your book, online tutorial, teacher, or whatever other resource you're learning from. – John Kugelman May 21 '17 at 00:49
  • 3
    Here is [The Definitive C++ Book Guide and List](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). –  May 21 '17 at 00:50
  • 1
    I'm sorry you feel that way, but I currently have a book called C++ for dummies, I just didn't understand it correctly. Also, Thank you Raw N for the source of information. – KiraCChan May 21 '17 at 00:50
  • @RawN I was tempted to dupe hammer that question going for your link. – πάντα ῥεῖ May 21 '17 at 01:24
  • 1
    I know, I'm not very smart. I'm trying though. Thank you for your input. – KiraCChan May 21 '17 at 01:27

3 Answers3

0
int main() {
    bool bacon = true;
    if (bacon)
    {
        printf("this worked?");
    }
}

The function you were looking for is printf, for "Print Formatted"

abelenky
  • 63,815
  • 23
  • 109
  • 159
0

Don't wrap bacon variable by double quotes in if condition. Change it to

 if (bacon == true)

OR simply

if(bacon) //this is equal to bacon == true
PEHLAJ
  • 9,980
  • 9
  • 41
  • 53
-1

Another way to do it would be:

int main() {
    bool bacon = true;
    if (bacon == true)
    {
        printf("this worked?");
    }
}

or:

int main() {
    bool bacon = true;
    if (bacon != false)
    {
        printf("this worked?");
    }
}

or:

int main() {
    bool bacon = true;
    if (bacon != 0)
    {
        printf("this worked?");
    }
}

or:

int main() {
    bool bacon = true;
    if (!bacon == false)
    {
        printf("this worked?");
    }
}

or:

int main() {
    bool bacon = true;
    if (!bacon == false)
    {
        printf("this worked?");
    }
}

or:

#include <iostream>
int main() {
    bool bacon = true;
    if (bacon)
    {
        std::cout << "this worked?";
    }
}

Hopefully, that will give you enough different ways to think about :). By the way, be very careful not to use a single = for comparing things!

Also, you probably should spend at least an hour or two trying to figure things out on your own before you post here because people tend to get overly aggravated about helping people they have personally decided haven't put their own work into the problem. For the same reason, you should give as much information as possible about what you have tried already, which also helps speed up the process of having your question answered.

  • Thank you for the variations! I will certainly think about these various ways, and find the most efficient in them. Also, good to know. I thought it was ==, because LUA.RBX does it like that when comparing, then again, it's a scripting language... Also, regarding the last part, I will spend more time searching, as I have noticed people like πάντα ῥεῖ have gone out of their way to vent their frustration of "inadequate" questions upon me, when as others have stated, there are various resources. I just didn't know where to start. Again, thank you for your positive and quite informative answer! – KiraCChan May 21 '17 at 02:28