C++ examples for Statement:if
The else and else if Statements
#include <iostream> using namespace std; int main(int argc, const char * argv[]) { if (false) { // w w w . j a v a2 s .c o m cout << "Print This When True!"; } else { cout << "Print This When False!"; } return 0; }
The else if Statement
#include <iostream> using namespace std; int main(int argc, const char * argv[]) { if (false) { //from w w w . ja v a 2 s .co m cout << "Print This When True!"; } else if (true) { cout << "Print This When Else If Is True!"; } else { cout << "Print This If All False!"; } return 0; }