Programming using C following the instruction below includin
Programming using C++ following the instruction below, including every comment for each step to explain what it does.
Make sure your program display the same as Figure 4, 5, 6 and 7.
Solution
#include <iostream>
 #include <string>
 using namespace std;
int main(){
     string password;
     string outpass = \"\";
     /*Welcome message*/
     cout<<\"                                --------------------------\ \";
     cout<<\"                                Nancy\'s Password Generator\ \";
     cout<<\"                                --------------------------\ \ \ \";
     cout<<\"Please enter a 5 character word which will be used to generate a password: \";
     cin>>password; //taking password input
    if(password.length()!=5){
         cout<<\"\ Sorry, but that is not a 5-character string. Program will terminate\ \ \";
         cout<<\"Thank you for using Nancy\'s Password Generator Program\ \";
         return 0;
     }
     else{
         int i = 4; //initialising i at 4 to get reverse order of characters
         while(i>=0){ //while loop to iterate through the string
             char before = password.at(i); //getting character at position i in password input by user
             char after = char(int(before)-15); //char by subtracting 15 from ascii value
             outpass += after;
             i--;
         }
         cout<<\"\ Your password is \"<<outpass<<\"\ \ \";
         cout<<\"Thank you for using Nancy\'s Password Generator Program\ \";
     }
     return 0;
 }

