C++ FOR BEGINNERS (2025) - What is while loop, What is infinite loop PROGRAMMING TUTORIAL

preview_player
Показать описание
Iteration (looping) is a process where a set of instructions are repeated for a specified number of times or until a certain condition is met.
In while loop, the condition is evaluated first and if it results as true then the statements inside while loop are executed, this happens repeatedly until the condition results as false. When the condition results as false, the control comes out of the loop and goes to the next statement in the program after while loop.
In this video, I'm explaining how is while loop used and what is an infinite loop and how to prevent your program from entering in an infinite loop.

📚 Learn how to solve problems and build projects with these Free E-Books ⬇️

Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.

Follow me on other platforms:

*******CODE IS IN THE COMMENTS*******
Рекомендации по теме
Комментарии
Автор

📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
Experience the power of practical learning, gain career-ready skills, and start building real applications!
This is a step-by-step course designed to take you from beginner to expert in no time!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.

#include <iostream>
using namespace std;

void main()
{
//Write out all the numbers between 100-500 that are
//divisible by 3 and 5

int counter = 100;
while (counter <= 500)
{
if (counter % 3 == 0 && counter % 5 == 0)
cout << counter << " is divisible\n";
counter++;
}

system("pause>0");
}

CodeBeauty
Автор

I find your C++ videos some of the easiest to learn from. Thank you!

LymariArzola
Автор

thank you for this video, really helped me understand how while works, plus its nice seeing someone not have the code done already and expect me to understand immediately what we're doing. Great work!

RandomLper
Автор

Na stranu komentari sto se tiče ljepote ali sto ti imaš prijatan glas za slusat i jako je poučno programiranje na način na koji ti prezentujes
Pretplaćen sam sa dobrim razlogom!
Samo nastavi raditi ono sto najbolje znaš 🙂

muhameddurmic
Автор

Thank you so much. I'm really lucky to watch your videos.

mohamedmoussa
Автор

Amazingly well explained! Thank you...

christosioannou
Автор

Thank you. I sincerely appreciate your efforts to teach this topic. My youngest son is learning to program and we have been watching your content as part of the endeavor.

The infinite loop should not consume more RAM for each iteration unless one or more of the following conditions exist:
1. Your compiler is dysfunctional
2. Your IDE is dysfunctional
3. Your iostream implementation of cout is defective

When I compile this example and inspect the assembly code, I observe no evidence of memory leaks.

merlingrim
Автор

Hvala lijepa na ovoj prilici da nesto korisno naucimo iz vasih tako dobro pripremljnih videa. Hvala velika! Pozz. P.S:"Jedina stvar koja se djeljenjem uvecava jeste znanje" !

imrek
Автор

This is amazing 200% gold. There I be trying to learn loops in codecademy it just doesn’t explain it like a video human can

nottingham-vjsv
Автор

These videos are great, I already know C pretty well, and have experience with C++, but zero fundamentals training. So a pretty face makes it easy to watch even if I know how the structure of C programming works. I have an idea and want to create my own program, and it looks like you do eventually touch on that. Hopefully you clear things up, as I got really confused with all the different templates (win32, ATL, CLI, MFC, CRT, Windows Desktop Wizard, Windows Desktop Application, etc, ...) even after researching these for days. Thanks, and looking forward to the rest of your content!

tomiadventures
Автор

Thank you so much for your explanation. One question I have, what do you mean by arrigning the 3% ==0? ...Does this have to do with the modulus operator ?

dboone
Автор

@CodeBeauty is such a good teacher. I made a guessing game just by learning this tutorial.

#include <iostream>
using namespace std;

int main()
{
int guessing_word, guess, current_limit = 0, max_limit = 3;
bool victory = false;

cout << "Enter Guessing word: ";
cin >> guessing_word;

while (current_limit < max_limit && guessing_word != guess && !(victory))
{
current_limit++;
cout << "Enter Your Guess: ";
cin >> guess;
}
if (guessing_word == guess)
{
victory = true;
}
else
{
victory = false;
}

if (victory)
{
cout << "You Won!";
}
else
{
cout << "Out of Guesses!";
}
}

humaankashif
Автор

Hi Mam, l hope you are well.Thanks for uploads this vidoes .lt is really help me .

ayaanabbasi
Автор

Just curious why you put the \n ? Maybe I missed this in one of your other videos.

thecariatikid
Автор

I have a question the code you wrote put all the divisibles but how can I know whixh one is divisible by 3 alone and which by 5 alone. This programs just writes them without specifying. So how can I know.

husseinmahmoud
Автор

How do we right a program in controlling and incubator

awemorolland
Автор

I was able to improve your code so it tells whether the numbers are divisible by 3 or 5 or both and also not repeat numbers thanks to your previous video on operations.

ebenaddo
Автор

Can we run the same code in turbo c++ or we have to make some changes in code please reply mam

preezyff
Автор

This example shows the 'else' statement can be omitted if it does nothing.

emuejevokesalvage
Автор

I made a mistake in the code, and it was printing all of the numbers and it was so silly XD I had a semi colon after the if statement

Wolfgirl-biie