User Input Validation With A Do-While Loop | C++ Example

  Рет қаралды 16,497

Portfolio Courses

Portfolio Courses

Күн бұрын

Пікірлер: 24
@justfred6863
@justfred6863 Жыл бұрын
Thanks alot, helped me for a college work!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You’re welcome, I’m glad to hear this helped you out! :-)
@クリスチャン-y5f
@クリスチャン-y5f Ай бұрын
Thank you bro
@sekke-c4f
@sekke-c4f Жыл бұрын
The video helps a lot thanks, but i have 1 question though why would you put the same condition on both if else statement and the while?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
The if-statement and condition there is to output the error message, the loop and condition there is to keep the loop going and ask the user to input the month again if the input was invalid. :-)
@210matrix
@210matrix Жыл бұрын
simple and informative. Thanks
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You’re welcome! :-)
@jonnymcgrath4816
@jonnymcgrath4816 Жыл бұрын
How can I do the same for multiple input? (Im saying if I want to do for another loop for input validation?)
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You could put one loop after the other, one at a time for each input. :-)
@jonnymcgrath4816
@jonnymcgrath4816 Жыл бұрын
@@PortfolioCourses thx for the fast response :)
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You're welcome! :-)
@abdulhamidfayziyev9293
@abdulhamidfayziyev9293 2 жыл бұрын
Please can you do this problem and make video. "Write C++ program to print the following triangle of numbers where the example height depends on user input. In case 0 is entered , print the depth is 0. Use for loop" .
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
Maybe Abdulhamid, but what does the triangle of numbers look like though? It says "the following triangle of numbers" but there is no triangle of numbers.
@abdulhamidfayziyev9293
@abdulhamidfayziyev9293 2 жыл бұрын
@@PortfolioCoursesfor example if you input 4 , output should look like this 4444 333 22 1
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
@@abdulhamidfayziyev9293 Hmm maybe I can do this, that doesn't seem too bad. 🙂
@abdulhamidfayziyev9293
@abdulhamidfayziyev9293 2 жыл бұрын
@@PortfolioCourses when will you do this brother?
@abdulhamidfayziyev9293
@abdulhamidfayziyev9293 2 жыл бұрын
@@PortfolioCourses can you do this within 15 hours.
@MuhammadUsman-mk4ii
@MuhammadUsman-mk4ii 9 ай бұрын
What if we use string
@ibrahimalnajjar277
@ibrahimalnajjar277 Ай бұрын
Error
@Sizdothyx
@Sizdothyx Жыл бұрын
What if I want to initiate this loop in the case of other invalid characters as well? As in, let's say I only want a number between 1-5, but putting in a character such as "a", I find, still doesn't activate the loop. The program acts as if it's a valid input.
@PortfolioCourses
@PortfolioCourses Жыл бұрын
Great question! This loop is only setup to handle int values. If we wanted to handle any type of input, we could accept the user input as a string, perhaps by using getline: kzbin.info/www/bejne/paWVd6yriZqrpsk. We could then parse the string to first see if it contains a valid int value at all before checking to see if the int value is in range, perhaps using a simple technique such as this: www.tutorialspoint.com/how-to-check-if-a-c-cplusplus-string-is-an-int. 🙂
@Adam-kk7nw
@Adam-kk7nw 2 жыл бұрын
Thanks
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're welcome Adam! :-)
FizzBuzz Problem | C++ Example
6:38
Portfolio Courses
Рет қаралды 2,7 М.
Advanced Integer Input Validation | C Programming Example
22:59
Portfolio Courses
Рет қаралды 12 М.
Disrespect or Respect 💔❤️
00:27
Thiago Productions
Рет қаралды 29 МЛН
Wait for it 😂
00:19
ILYA BORZOV
Рет қаралды 11 МЛН
I tricked MrBeast into giving me his channel
00:58
Jesser
Рет қаралды 28 МЛН
Learn C++ With Me #11 - While, Do While Loops & Break/Continue
24:01
C++ Tutorial -   Loops In C++ [For Loop, While Loop, Do While Loop]
16:20
you will never ask about pointers again after watching this video
8:03
C++ Programming Tutorial 39 - Do While Loop
8:35
Caleb Curry
Рет қаралды 48 М.
Loops in C++ (for loops, while loops)
12:20
The Cherno
Рет қаралды 414 М.
15 Years Writing C++ - Advice for new programmers
4:04
SyncMain
Рет қаралды 1,2 МЛН
C++ Validating Input with a while Loop
7:23
profgustin
Рет қаралды 88 М.
While Loop with Guessing Games - C++ Tutorial 14
8:03
Caleb Curry
Рет қаралды 3,3 М.
Disrespect or Respect 💔❤️
00:27
Thiago Productions
Рет қаралды 29 МЛН