do{
cout << "Enter a character ";
cin >> aChar;
var = aChar;
cout << " achar encripted is " << encript(aChar);
cout << " achar was " << var << " now is " << aChar << endl;
# include <iostream>
# include <cstdlib>
usingnamespace std;
// I need to define the encript function here
// the exception of A | a which should return a 9; if you think at this way
// better to not return anything and just add another condtion to the do while loop
// ( checkit(var)&&var!='A');
void encript(char &ch)
{
while(true)
{
int rndNbr = rand()%255;
if(rndNbr>=128&&rndNbr<=150)
{
ch = char(rndNbr);
break;
}
}
}
bool checkit( char inChar )
{
if( inChar != '9' ) returntrue;
returnfalse;
}
int main(int argc, char* argv[])
{
char aChar;
char var;
do{
cout << "Enter a character ";
cin >> aChar;
var = aChar;
// cout << " achar encripted is " << No need for this one ;
encript(aChar);
cout << " achar was " << var << " now is " << aChar << endl;
}while ( checkit(var) );// Turn aChar to var because aChar encripted right now and never get 9
// in our case , ps to end the loop enter 9
return 0;
}
I appreciate your help. I am going to rewrite my function the way that it returns the previous letter . For example I B M and returns H A L. Do you recommend anthing?