Write a C++ code that asks the user's name, then the code will ask the user to guess the password of four digits. The code will give the user four chances to enter a number of two digits for each time. If the user entered one digit number the code will show the following message "wrong number, it should be between 10 to 99" as shown in the first picture. On the other hand, if the user entered two digits number, the code will compare it with the password, and it will show message as in picture two. (Every student has his /her own password) what is your name Mohammad Hi Mohammad you have four times to guess the password Mohammad make your guess pick any number of two digits (10 to 99) :5 wrong number, it should be btween 10 to 99 Process exited after 14.62 seconds with return value e Press any key to continue what is your name Mohammad Hi Mohammad you have four times to guess the password Mohammad make your guess pick any number of two digits (10 to 99) :75 wrong guess! Mohammad make your guess pick any number of two digits (10 to 99) :26 the number is *2** Mohammad make your guess pick any number of two digits (10 to 99) :13 the number is 123* Mohammad make your guess pick any number of two digits (10 to 99) :48 the number is 1234 Process exited after 48.28 seconds with return value e Press any key to continue
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.


Step by step
Solved in 2 steps with 1 images









