(Last Revision -- 03/12/00)

if-Statement and else-Statment Example Adapted from Astrachan's Tapestry

#include <iostream.h>
#include <string>

/* illustrates use of if-else statement */

int main(void)
{
    string response;
    
    cout << "Do you like broccoli [yes/no]> ";
    cin >> response;

    if ("yes" == response)
        cout << "Green vegetables are good for you" << endl;

    else
       cout << "There is no accounting for taste" << endl;
       
    return 0;
}