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?");
}
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?");
}
int main() {
bool bacon = true;
if (bacon)
{
printf("this worked?");
}
}
The function you were looking for is printf
, for "Print Formatted"
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
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.