Hey guys, I'm just doing this code to see if it works where the user inputs a name and it outputs a menu where different options can be chosen.
For example, if the user press 1 the outputs of the name is reversed, if 2 is pressed the name is vertically forward slash, if 3 is pressed the name is vertically reversed backward slash, and if the user press 4, the name appears in a form of a triangle:
Here is part of my code but I don't know what is wrong with CASE 3, backward slash. Thank you in advance for any help!
int main(){
string nm;
cout<<"Hello! Please type only your first name: "<<endl;
cin>>nm;
int opt = 0;
while (opt != 5){
cout<<"Choose from the following options!\n"
"if you want your name to be displayed...\n"
"Reversed.......... press 1,\n"
"Vertically-forward slash.......... press 2,\n"
"Vertically reversed-backward slash.......... press 3,\n"
"In form of triangle.......... press 4,\n"
"Exit the program.......... press 5.\n";
cin>>opt;
int s = 0; //variables declared for case 2
int s1 = 0;
int s2 = 1; //variables declared for case 3
int s3 = 1;
switch (opt){
case 1:
revnm(nm);
cout<<endl;
break;
case 2:
fwd_slah(nm);
for(int i=0; i<nm.size(); i++){
for(int k=0; k<s; k++)
cout<<" ";
cout<<nm.substr(s1,1);
cout<<endl;
s++;
s1++;
cout<<endl;
}
break;
case 3:
bwd_slah(nm);
for(int i=0; i<nm.size(); i++){
for(int k=0; k<s2; k++)
cout<<"";
cout<<nm.substr(s3,0);
cout<<endl;
s2--;
s3--;
cout<<endl;
}
break;