C++ examples for Statement:if
A simple if-else statement
#include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv []) { cout << "Please input a number greater than or equal to 0: "; int aNumber; cin >> aNumber; /*from w ww.j a v a 2 s. com*/ if (aNumber >= 0) { cout << "Very good." << endl; } else { cout << "Not very good." << endl; } return (0); }