Skip to Content
While Loop Demo

So first up… the while loop!

Before we dive deep into the syntax of the while loop, let’s do a demo.

Inside enter_pin.cpp, we have a program that asks and checks for a password. It uses a while loop to ask the user for the password over and over again.

Note: You don’t need to understand the code right now.



Compile and execute using the terminal.

When the program asks you to Enter your PIN:, try the following:

Press 1111 and press enter.

Press 2019 and press enter.

Press 1234 and press enter.

Folder Icon

Take this course for free

Already have an account?