Question

pls help

2. Design a password generator that takes input from the user in the form of string and are integer. A string consists of fou

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Program

#include<iostream>
using namespace std;

void swap(char arr[],int i,int j){
   char temp = arr[i];
   arr[i] = arr[j];
   arr[j] = temp;
}
void swapString(string& str,int i,int j){
   char temp = str[i];
   str[i] = str[j];
   str[j] = temp;
}

void Password(string str , int number){
   char num[4];
   int i=0;
   while(number){
       num[3-i] = number%10+'0';
       number/=10;
       i++;
   }
   swap(num,0,2);
   swap(num,1,3);
  
   swapString(str,0,3);
   swapString(str,1,2);
  
   string password="";
   password+=str[0];
   password+=str[1];
   for(int i=0;i<4;i++)password+=num[i];
   password+=str[2];
   password+=str[3];
  
   cout<<"password : "<<password;
}

int main(){
   string str;
   int number;
  
   cout<<"Enter string : ";
   cin>>str;
  
   cout<<"Enter 4-digit integer : ";
   cin>>number;
   Password(str,number);
   return 0;
}

//sample output

CAUsers\IshuManish\Documents\passwordd.exe asdf Enter string : Enter 4-digit integer 1234 password fd3412sa Process exited af

Add a comment
Know the answer?
Add Answer to:
pls help 2. Design a password generator that takes input from the user in the form...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the Code in C program. Create a random password generator that contains a user-specified number...

    Write the Code in C program. Create a random password generator that contains a user-specified number of characters. Your program should prompt the user for the desired length of the password. Length of password: To create your password, use the random number generator in the stdlib.h C library. To generate random numbers, you will need the srand() and rand() functions. srand(seed) is used to "seed" the random number generator with the given integer, seed. Prompt the user for the seed...

  • Write a program that asks the user to enter a password, and then checks it for...

    Write a program that asks the user to enter a password, and then checks it for a few different requirements before approving it as secure and repeating the final password to the user. The program must re-prompt the user until they provide a password that satisfies all of the conditions. It must also tell the user each of the conditions they failed, and how to fix it. If there is more than one thing wrong (e.g., no lowercase, and longer...

  • need help with this JAVA lab, the starting code for the lab is below. directions: The...

    need help with this JAVA lab, the starting code for the lab is below. directions: The Clock class has fields to store the hours, minutes and meridian (a.m. or p.m.) of the clock. This class also has a method that compares two Clock instances and returns the one that is set to earlier in the day. The blahblahblah class has a method to get the hours, minutes and meridian from the user. Then a main method in that class creates...

  • Thank you Please show all work Thanks 76.) [ 10 pts ] Consider the two S-boxes...

    Thank you Please show all work Thanks 76.) [ 10 pts ] Consider the two S-boxes S1 and S2 of DES shown. Three hex digits (12 bits) are provided to these two S boxes. The higher order six bits are fed to S1 and the lower order six bits are fed to S2. For the six bits input to S1, the first and last bits are used to select the row, and the middle four bits are used to select...

  • A complex number is a number in the form a + bi, where a and b...

    A complex number is a number in the form a + bi, where a and b are real numbers and i is sqrt( -1). The numbers a and b are known as the real part and imaginary part of the complex number, respectively. You can perform addition, subtraction, multiplication, and division for complex numbers using the following formulas: a + bi + c + di = (a + c) + (b + d)i a + bi - (c + di)...

  • Task 1: Write a Python program that takes as input from the user the name of a file containing po...

    python code: Task 1: Write a Python program that takes as input from the user the name of a file containing postcode/location information. Each line in the file consists of the postcode followed by a tab followed by a comma-separated list of locations that have that postcode. For example, the file Small.txt contains: 3015 Newport,South Kingsville,Spotswood 3016 Williamstown 3018 Altona,Seaholme 3019 3021 Albanvale,Kealba,Kings Park,St Albans Braybrook, Robinson Your program should create a list of postcode/location pairs with each pair stored...

  • Write a C program for: One technique for dealing with deadlock is called “detect and recover.” In...

    Write a C program for: One technique for dealing with deadlock is called “detect and recover.” In this scheme, some procedure is used to identify when a deadlock occurs, and then another procedure is used to deal with the blocked processes. One technique to identify a deadlock is to maintain a resource graph that identifies all processes, all resources, and the relationships between them (that is, which processes exclusively own which resources, and which processes are blocked waiting for which...

  • QUESTION 11 Which instruction is used to return from a user function to its caller? return...

    QUESTION 11 Which instruction is used to return from a user function to its caller? return eret jal jr 1 points    QUESTION 12 Which of the following is the best description of memory mapped input/output (MMIO)? the ability to use a common address space to access memory as well as input/output devices. the ability to read characters from the keyboard the ability to interrupt the CPU when the result of an operation involving an IO device is complete. the...

  • DIRECTIONS FOR THE WHOLE PROJECT BELOW BigInt class The purpose of the BigInt class is to...

    DIRECTIONS FOR THE WHOLE PROJECT BELOW BigInt class The purpose of the BigInt class is to solve the problem using short methods that work together to solve the operations of add, subtract multiply and divide.   A constructor can call a method called setSignAndRemoveItIfItIsThere(). It receives the string that was sent to the constructor and sets a boolean variable positive to true or false and then returns a string without the sign that can then be processed by the constructor to...

  • im currently doing an assignment where i must design a two stage bipolar transistor, i just...

    im currently doing an assignment where i must design a two stage bipolar transistor, i just need the calculations and values for each component and then i can run simulated experiments and complete my work here is the schematic the transistor used is the BC846B the supply voltage is 15 v the collector currents 1 (ICq1) = 1.5mA the collector current 2 (ICq2) = 7.5 mA output voltage swing= max frequency response = 50- 20 khz i must calculate the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT