I have a function, but I need the ENTIRE code. void myAscii(char ascii, int a) {
ID: 3656594 • Letter: I
Question
I have a function, but I need the ENTIRE code. void myAscii(char ascii, int a) { if (a <= 0) cout << endl; else { myAscii(ascii - 1, a - 1); cout << ascii; myAscii(ascii + 1, a - 1); } } I need an entire code that will allow me to input different values (character, integer) so I can log the outcomes. For example, I need to be able to just plug in ascii('P', 3) and get a returned result. I don't need to write the code so I am asking you to do that for me. I just need to be able to walk through it and provide results to various scenarios. Thank you.Explanation / Answer
#include<iostream.h>
void myAscii(char,int);
int main()
{
char ch;
int i;
cout<<"Enter character"<<endl;
cin>>ch;
cout<<"Enter the integer value"<<endl;
cin>>i;
myAscii(ch,i);
return 0;
}
void myAscii(char ascii, int a)
{
if (a<=0)
cout << endl;
else
{
myAscii(ascii-1, a-1);
cout << ascii;
myAscii(ascii+1, a-1);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.