(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 with compound statements. */
int main()
{
string response;
cout << "Do you like broccoli [yes/no]> ";
cin >> response;
if ("yes" == response)
{
cout << "Green vegetables are good for you" << endl;
cout << "Broccoli is good in Chinese food as well" << endl;
}
else
{
cout << "De gustibus non disputandum" << endl;
cout << "(There is no accounting for taste)" << endl;
}
return 0;
}