I am new to C++ and I have some confusion regarding this program. I am running this in Visual Studio 2008 as win32 console application.
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;
#define PI 3.14
int l=1;
int x;
void main()
{
do
{
cout << "choose 1";
cout << "choose 2";
cin >> x;
switch(x)
{
case 1:
cout << "action 1";
break;
case 2:
cout << "action 2";
break;
default:
cout << "unknown command";
break;
}
} while (l=1)
}
When I run this program and type anything else than 1 or 2, it is not displaying the default option in the switch. I am unable to figure out the problem. How do I fix this problem?