how can i make the program loop instead of "press any key to continue"?
my calculator will not do this (it says main() is unidentified) in vc++
Code:
#include <iostream.h>
#include <conio.h>
int ad()
{
cout<<"Enter two numbers to add:\n";
int x,y;
cin>>x;
cin>>y;
cout<<"="<<x+y<<"\n";
return 0;
}
int subt()
{
cout<<"Enter two numbers to subtract:\n";
int x,y;
cin>>x;
cin>>y;
cout<<"="<<x-y<<"\n";
return 0;
}
int divi()
{
cout<<"Enter two numbers to divide:\n";
int x,y;
cin>>x;
cin>>y;
cout<<"="<<x/y<<"\n";
return 0;
}
int multi()
{
cout<<"Enter two numbers to multiply:\n";
int x,y;
cin>>x;
cin>>y;
cout<<"="<<x*y<<"\n";
return 0;
}
int main()
{
cout<<"1: add\n";
cout<<"2: subtract\n";
cout<<"3: multiply\n";
cout<<"4: divide\n";
int input;
cin>>input;
switch (input)
{
case 1: ad();
break;
case 2: subt();
break;
case 3: multi();
break;
case 4: divi();
break;
default: main();
}
return 0;
}