C++ FOR BEGINNERS (2025) - How to nest loops, How to nest for and do-while loop PROGRAMMING TUTORIAL

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 61

  • @CodeBeauty
    @CodeBeauty  4 года назад +21

    📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
    C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book
    Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook
    🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/
    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
    using namespace std;
    void main()
    {
    int grade, sum = 0;
    for (int i = 0; i < 3; i++) {
    do {
    cout

    • @Hylocichla
      @Hylocichla 4 года назад

      I am having trouble getting your code to run. I copy and paste the code above and then get the following error message:
      C:\Users\mark_\myCppprograms>c++ nested_loops_codebeauty_her_code.cpp -o nested_loops_codebeauty_her_code.exe
      nested_loops_codebeauty_her_code.cpp:6:11: error: '::main' must return 'int'
      void main()

    • @CodeBeauty
      @CodeBeauty  4 года назад +1

      @@Hylocichla Try this 😊
      Instead of having void main(), write int main()
      And before your last "}" put
      return 0;

    • @Hylocichla
      @Hylocichla 4 года назад +1

      I can get your code to run if I change one line:
      // void main()
      int main()

    • @rudebee15
      @rudebee15 3 года назад

      how do you set the decimal point to two decimals only?

    • @branriv8417
      @branriv8417 3 года назад +1

      @@rudebee15 i was going to ask the same question and as I saw you already did I think the answer kind of came to me. I think there is a function similar to the setw( )function. Not totally sure what it is but I bet a Google search would find it quickly. You would need the necessary header file too.

  • @iamfine75
    @iamfine75 Год назад +5

    She is that teacher you will fall in love with!

  • @emuejevokesalvage8802
    @emuejevokesalvage8802 2 года назад +12

    One important lesson I have learnt from your videos is not to try to memorize code but to first fully understand the problem and the steps to solve it. And then translate that into code.

    • @CodeBeauty
      @CodeBeauty  2 года назад

      This is the best advice that will help you to learn programming! ☺️

  • @CathleenAbila
    @CathleenAbila Год назад

    This channel helped me a lot. The only woman who makes coding more understandable .

    • @milanrai1556
      @milanrai1556 6 месяцев назад

      woman .....?? Really ..... ? You have no respect for your mentor ??

  • @turpialito
    @turpialito 4 года назад +16

    You made me smile, and you made the rest of the lesson so enjoyable! Did you make a course blooper reel? I'd enjoy seeing more funny out-takes!

  • @titis709
    @titis709 3 года назад +1

    Thank you so much!! I was able to finish my project because of you. :')

  • @1conscience0dimension
    @1conscience0dimension 3 года назад

    several days ago, I was like why learning programming is so cold to learn? and then I arrived here. you make it more human

  • @antonio6140
    @antonio6140 4 года назад +3

    Just writing this to make sure I understood.
    So, for an i variable that is between 0 and 2, the program will prompt the user
    to enter a grade whose "order" number is that of the i variable + 1. If I understood correctly the program won't register this as an increment, but
    rather this is used for display purposes only (i.e the i variable starts at 1 in the cout prompt, but for all other purposes it actually starts at 0,
    then 1, then 2). So after that, the program checks if the grade variable has a value below 1 and above 5, and if so it will prompt the user to input the grade again without incrementing the i value. This is happening because the program can't return to the for loop while this condition is true. When it's not true (i.e values between 1 and 5) the program returns to the for loop, increments i by 1 and asks for the next grade. So that while loops exists really just to make sure the user doesn't cheat and enter whatever values they want.

  • @kevinlopez9047
    @kevinlopez9047 4 года назад +4

    how do you make the font bigger or smaller? what quick tabs do you use? love your videos btw!

    • @CodeBeauty
      @CodeBeauty  4 года назад +4

      Thanks Kevin :D
      You can right click on the console window, click Properties and there you can change font, colors, layout...
      When it comes to the second part of your question, you can google "Shortcut tips for Visual Studio 2019", and there you can find a lot of useful shortcuts :smile:

  • @ChrisVideosGreek
    @ChrisVideosGreek 3 года назад +1

    First time making a intro!!! So funny xD

  • @ROYALNIL_SITE
    @ROYALNIL_SITE Год назад

    thanks ,your train is good

  • @ajayaddada
    @ajayaddada 3 года назад +2

    Hi I didn't understand why you have used
    while (grade5);
    What does grade5 mean?

    • @day4834
      @day4834 2 года назад +2

      Hi, this means that the program is going to ask you to enter a grade again if it's lower that 1 or higher than 5 - this condition makes sure the program only accepts grades that are {1,2,3,4,5}. The sign "||" stands for "or".

  • @qaiserakram241
    @qaiserakram241 3 года назад

    i run the program with both int and void and the result was same
    will it be same niversally aswell?
    please explain

  • @omaristaitia5628
    @omaristaitia5628 3 года назад

    very nice thank you Ms

  • @cuol5675
    @cuol5675 3 года назад

    whats the propose of Avg ? idk maybe schools are different in other countries or maybe i just never noticed the avg grade or didn't care i don't know pls explain :)

  • @roukayaroukaya5289
    @roukayaroukaya5289 3 года назад +1

    why we used void main()

  • @safak2492
    @safak2492 3 года назад +1

    We are using "for (int i = 0; i < 3; i++)" and its loops 3 times but code never rewrite "int i=0" after each loop, i cannot understand the logic because code do not store any data after i++

    • @tj3603
      @tj3603 2 года назад

      It does store data inside 'grade' and 'sum' variables, and it overwrites 'i' because of 'i++' argument.

  • @tumusiimebrian3745
    @tumusiimebrian3745 4 года назад +1

    Why do we use void instead of int at the beginning??

    • @CJ2345ish
      @CJ2345ish 8 месяцев назад

      you could put either, but that "int" or "void" is if you are returning a value somewhere you use that to determine what the return data type is. If you look at her last video, say you put the factorial code into a function called "Factorial" and you want to return a value, you'd say "int Factorial" but in this case, the main method returns no value so you can use void. She uses int in other cases and that's not inherently wrong, but she doesn't actually return anything.

  • @DrToonhattan
    @DrToonhattan 3 года назад +3

    I rewrote this program so the user can input grades as letters from A* to F, it then converts them to numbers, takes the average, then spits back out a letter grade. There's probably a more efficient way of doing it than just using a bunch of if statements, but this was the only way I could think of that worked.
    Here's my code:
    #include
    #include
    using namespace std;
    int main()
    {
    string gradeLetter;
    int gradeNum, loopCounter, sum=0;
    cout loopCounter;
    for(int i=0; i

    • @sogli43
      @sogli43 3 года назад

      OK, I don't understand American grading system. Can you explain me the difference between A and A*, also what every letter represent? Where I come from 5 is the best grade you can get and 1 is the worst, so how would you compare it to our grading sys so that I could understand your code better.

    • @karkarplays3798
      @karkarplays3798 2 года назад

      if you want to limit the amount of if statements then maybe try formatting it using case statements, same thing but more efficient i think for what you are trying to do!

  • @sioh3
    @sioh3 3 года назад

    What font are you using in this video?

  • @lexie_tiano
    @lexie_tiano 3 года назад

    I transformed 'grade' and 'sum' into floating point type variable (float) instead of integer variable (int) so that:
    1) I may enter grades with decimals
    2) I don't need to turn them into (float) or decimal to do the average.
    Thank you so much for your videos. You make learning a pleasure. (And the bloopers were very funny)

    • @day4834
      @day4834 2 года назад

      Hi Alexandra, I think the original solution from the author is better since you don't get a 1.5 grade but 1 or 2 and hence the sum can only be a whole number (1+2=3). However, the average may be a decimal number so it makes sense to go for a variable data type that can hold a decimal value.

  • @traianbadea7389
    @traianbadea7389 4 года назад

    Sorry I correct my previous phrase and the correct is ;
    So if the grade is different from 76 or 73, the program must runs to the same Etapa. And when I enter the 76 or 73 the program must to run to the next level of Etapa because do not meet the condition of while to repeat the same level of Etapa. ..and pass to the next level of Etapa.. in my conception ..but is not working. The loop continua with the same Etapa that means is stoped at previous Etapa.
    So I do not understand where I mistake.
    All the best

  • @jerseychou4323
    @jerseychou4323 Год назад

    thanks

  • @mhdjaseem3195
    @mhdjaseem3195 3 года назад

    thanks, mam💕💖

  • @IAmIshanSaxena
    @IAmIshanSaxena 4 года назад

    can we write
    :while(grade>=1||grade 5);???
    i don't understand why my syntax didn't work??
    Both does the same work??

    • @rajk9989
      @rajk9989 4 года назад

      The reason your code does not work is because, first.) the do-while loop is suppose to continue to loop if the user has not entered a correct value. For her program, In this case, it will continue to ask the user for a grade until they enter a valid grade, the outer loop will then increment once the correct value is entered. Your loop says if they enter a value greater than or equal to 1 or less than or equal to 5, continue to do the "do." Try entering a negative value or a value greater than 5, 3 times, it will increment 3 times and exit the loop because the condition is not being met.

    • @sanikadawre3612
      @sanikadawre3612 3 года назад

      @@rajk9989 this might be a silly doubt but a number that lies between 1 and 5 should be greater than or equal to1 and less than or equal to 5 right?

  • @traianbadea7389
    @traianbadea7389 4 года назад

    #include "pch.h"
    #include
    using namespace std;
    int main()
    {
    cout

  • @ucfunnyvideochannel2695
    @ucfunnyvideochannel2695 2 года назад

    Why do you set I value to be zero

  • @AdityaSharma-hi9ie
    @AdityaSharma-hi9ie 2 года назад +2

    I didnt used nested loops,I just used one loop and made the same program.....
    #include
    int main()
    {
    int grade, sum = 0;
    for (int i = 0;i < 3;)
    {
    std::cout 0&&grade

  • @ucfunnyvideochannel2695
    @ucfunnyvideochannel2695 2 года назад

    Why do you always use single alphabet when it comes to loop

  • @추-b1n
    @추-b1n 3 года назад

    do {
    cout

    • @usgreth
      @usgreth 3 года назад +1

      No, you are adding the value of grade to sum before checking if that value is okay to use.

  • @amiganer681130
    @amiganer681130 3 года назад

    All the mistakes makes you human. *smile*

  • @imnot9923
    @imnot9923 2 года назад

    Comment for Algor

  • @programmer5177
    @programmer5177 3 года назад

    Without the specs you look Very pretty 😀

  • @painkillergko
    @painkillergko 3 года назад

    In some time I will be able to focus on what is the subject of the film ...

  • @visionvision5089
    @visionvision5089 2 года назад

    You are so cute @ 0:04.

  • @SAM-if6vv
    @SAM-if6vv 2 года назад

    You are not saying clearly

  • @CathleenAbila
    @CathleenAbila Год назад +1

    This channel helped me a lot. The only woman who makes coding more understandable .