Created
May 11, 2018 16:34
-
-
Save edenizk/159019f7f44ab45ed7fa0322c16464be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <conio.h> | |
using namespace std; | |
/* run this program using the console pauser or add your own getch, system("pause") or input loop */ | |
////////////////////////////////////////////// | |
///////////////////////////////////////////// | |
//tester | |
int tester(int &a,bool &check){ | |
if(cin.fail()||a<=0){ | |
cin.clear(); | |
cin.ignore(10, '\n'); | |
cout<<"Choosen number is negative or not a number\n -Please write it again\n"; | |
cout<<"please write your number again(it must be a number and it cannot be negative number):\n"; | |
cin>>a; | |
if(cin.fail()||a<=0){ | |
cout<<"Please next time try to write a number or positive number..."; | |
return check=0; | |
} | |
} | |
}//tester | |
////////////////////////////////////////////// | |
///////////////////////////////////////////// | |
////////////////////////////////////////// | |
//////////////////////////////////////// | |
char againsaver(char again) | |
{ | |
if((again=='n')||(again=='N')) | |
{ | |
return again='n'; | |
} | |
else if((again=='y')||(again=='Y')) | |
{ | |
return again='y'; | |
} | |
else | |
{ | |
cout<<"\t-Please write [y/Y] for continue, and [n/N] for exit : "; | |
cin>>again; | |
if((again=='n')||(again=='N')) | |
{ | |
return again='n'; | |
} | |
else if((again=='y')||(again=='Y')) | |
{ | |
return again='y'; | |
} | |
else | |
{ | |
cout<<"\t -You kicked :P\n"; | |
system ("pause"); | |
return again='n'; | |
} | |
} | |
} | |
////////////////////////////////////////////// | |
///////////////////////////////////////////// | |
int main(int argc, char** argv) { | |
int rev=0,rem,num; | |
bool checker=1; | |
char again; | |
do{ | |
int rev=0,rem=0,num=0; | |
cout<<"\t - Please Write Number Which You Want to Reverse\n"; | |
cin>>num; | |
tester(num,checker); | |
if(checker==0){ | |
return 0; | |
} | |
while(num!=0){ | |
rem=num%10; | |
rev=rev*10+rem; | |
num/=10; | |
} | |
cout<<"your reversed number is "<<rev<<endl; | |
system ("pause"); | |
system("cls"); | |
cout<<"\n\t-Do you wanna choose it again ? [Y/N]\n"; | |
again=getch(); | |
again=againsaver(again); | |
system("cls"); | |
if((again=='n')||(again=='N')) | |
{ | |
cout<<"GOOD BYE "<<(char)1; | |
} | |
}while((again=='y')||(again=='Y')); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment