i cant get this code to loop back to the main() fuction. some time it does but not others
>>>>>>>>>>>>>>>>>>>>>Code<<<<<<<<<<<<<<<<<<<<<<
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include <conio.h>
int BYC();
int TDC();
int main()
{
int sel;
while (sel>4 || sel<1)
{
cout<<"1. Bet You Can't\n";
cout<<"2. Two Digit Calculater\n";
cout<<"3. \n";
cout<<"4. Exit\n";
cout<<"Enter selection 1, 2, 3 or 4: ";
cin>>sel;
if (sel>4 || sel<1)
{
cout<<"Error! No such input.\n";
}
else
{
}
switch (sel)
{
case 1:
BYC();
break;
case 2:
TDC();
break;
case 3:
break;
case 4:
break;
}
}
return 0;
}
int BYC()
{
char let;
while(let!='l')
{
for(int num=1;num<1000;num++)
{
cout<<"Bet You Can't Stop This!\n";
}
cout<<"I'll give you a chance to stop it(enter a letter):";
cin>>let;
}
cout<<"Lucky guess\n\n";
main();
return 0;
}
int TDC()
{
int n1;
char op;
int n2;
cout<<"This calculater can only calculater two intergers, * = Multiplycation,\n / = Division, + = Addition, - = Subtraction.\n";
cout<<"Enter first integer:";
cin>>n1;
cout<<"Enter a operator:";
cin>>op;
cout<<"Enter second integer:";
cin>>n2;
switch(op)
{
case '+':
cout<<n1+n2;
break;
case '-':
cout<<n1-n2;
break;
case '*':
cout<<n1*n2;
break;
case '/':
cout<<n1/n2;
break;
}
main();
return 0;
}



LinkBack URL
About LinkBacks



