Creating User Interface using switch and do while loop in C

For Complete YouTube Video: Click Here

In this class, we will be Creating User Interface using switch and do while loop in C.

We have already discussed concepts on the switch and do-while loop.

Using the switch statement and do-loop, we can create a user interface for the end-user.

What is meant by a user interface?

User Interface is a way to make the program user comfortable with what he has to do while the program is executing.

Creating User Interface using switch and do-while loop in C

Example

The image below is the program for the user interface.

Creating User Interface using switch and do while loop in C Example
Creating User Interface using switch and do while loop in C Example

The above program is a simple calculator capable of doing addition, subtraction, multiplication, and division.

The do statement has a switch statement that takes the option from the user.

The first five printf statements will let the user know which option to be provided for the calculator to do the necessary action.

The program will stop only if the user gives 0 options.

Otherwise, the program will iterate infinitely.

After giving the option, the corresponding simple calculation is done.

Once the user has done all his calculations, he should give 0 to stop the program.

If the user provides the wrong option, the default case will get executed, stating that he has provided the wrong option.