C++ - Programming Language
This course covers the basics of programming in C++. Work your way through the videos and we'll teach you everything you need to know to start your programming journey!

If Statements

Lesson 16
Author : Mike Dane
Last Updated : November, 2017


Code

Copybool isStudent = false;
bool isSmart = false;

if(isStudent && isSmart){
     cout << "You are a student" << endl;
} else if(isStudent && !isSmart){
     cout << "You are not a smart student" << endl;
} else {
     cout << "You are not a student and not smart" << endl;
}

// >, <, >=, <=, !=, ==
if(1 > 3){
     cout << "number comparison was true" << endl;
}

if('a' > 'b'){
     cout << "character comparison was true" << endl;
}

string myString = "cat";
if(myString.compare("cat") != 0){
     cout << "string comparison was true" << endl;
}