Buckys C++ Programming Tutorials – 24 – do while Loops

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

48 responses to “Buckys C++ Programming Tutorials – 24 – do while Loops”

  1. John Brown Avatar

    I remembered I had to use the do while loop because my code was working with the while loop. However I got the understanding of how to use while loop. Then I forgot and thank you for reminding me.

  2. Buffed Physics Avatar

    he sounds like ryan reynolds from deadpool hahaha .. probably he is the inspiration behind it

  3. TheVanIIshed Avatar

    Do While loops are pretty usefull if you ask the user whether he wants to repeat the programm, you just soround your progrmm with a do while loop and put a cin for a variable in that the user can choose whether he wants to repeat, and in the while statement after the loop you just test if the variable equal to yes or whatever and if it is itll repeat.

  4. TheWarfare07 Avatar

    if the program tests x = 99. why is there while x < 10 ? its just sitting there for nothing ?

  5. Seb Sharma Avatar

    7000 people left for the stock market

  6. Shuyanchi Avatar

    pretty cool huh?
    yes.

  7. usman khalifa Avatar

    i understand ur teachings way better than our lecturer

  8. Abjo Das Avatar

    Great Explanation man!!

  9. Langkopf Kopf Avatar

    love your humor and expressions

  10. aaron C Avatar

    pretty cool huh

  11. Vytazas Avatar

    #include <iostream>

    using namespace std;

    int main(){

    char op;
    double a;
    double b;

    do{
    cout << "Enter a number: ";
    cin >> a;

    cout << "Enter a operator(+, -, *, /: ";
    cin >> op;

    cout << "Enter a second number: ";
    cin >> b;

    if (op == '+') {
    cout << "The answer is: " << a + b << endl;
    }else if (op == '-') {
    cout << "The answer is: " << a – b << endl;
    }else if (op == '*') {
    cout << "The answer is: " << a * b << endl;
    }else if (op == '/') {
    cout << "The answer is: " << a / b << endl;
    }
    cout << "n";

    }
    while (op !='e');

    }

  12. Bryan SWAGGBEAST Avatar

    bro i actually thought he just taught c++ but i just realized that hes a genius and he also teaches math, chemistry and all the coding languages!

  13. Bryan SWAGGBEAST Avatar

    man i just love the way he says "Pretty cool huh?" lol

  14. TheFluffiePenguin Avatar

    Do we need #include <cmath> ?
    I'm using visual studio, I don't seem to need it.

  15. xdarkness22x Avatar

    While and do-while have always confused me. But the little examples you showed really help me contrast the two, and now I understand them. Thanks a lot 🙂

  16. kaiser Avatar

    im comfortable with dowhile than while actually 😉

  17. Jack Curran Avatar

    You have taught me so much this past week i have went from tutorial 0 to 24 and now know everything that was taught in between them! Thanks Bucky!

  18. Abhishek Suraj Avatar

    Damn dude!
    You are awesome, you thought me things in like 5 mts which my teacher couldn't teach in like a month !
    Thanks alot!
    Keep up the good work 🙂

  19. Jordan Filipovski Avatar

    These tutorials are so awesome. I love them. I give you a massive thumbs up and an imaginary burrito.

  20. Frank Lopez Avatar

    how do we have conditions change by outside  influences ? rather then by making a permanent code that you can only change by re Writing the code again or editing the sketch and re uploaded ?  kinda like a CIN function that can change the value of a variable or something ? like in a MCU you can have things like analog read pin/port who monitor the outside world and depending o the type of sensor or read you will get something diff so how do we do this in c++ when we build a computer program? like in HTML everything is based on the user where they click where they hover over links icons pictures or what not but it depends on the user so you can say theres a CIN like function that always depends on the user in order to move on so maybe we can hook up a MCU to the pc via USB or serial or wireless and the program will do what the code instructed of it based on the analog rad or digital read?

  21. Amul Bham Avatar

    i cant even describe how much your videos have helped me get through my c++ class. really helping me grasp the basics and syntax that is often brushed over in class. THANK YOU.

  22. EpicKingdom_ Avatar

    How do you stop the loop or prevent it from entering an infinite loop? 

    My code: 

    do 
    {
    switch (UserPlatformSelection) 
    {
    case 1: cout << "You have selected " << UserPlatformSelection << " (PS4)" << endl; // INFORM THE USER OF SELECTING PS4.
    break;
    case 2: cout << "You have selected " << UserPlatformSelection << " (Xbox One)" << endl; // INFORM THE USER OF SELECTING XBOX ONE.
    break;
    case 3: cout << "You have selected " << UserPlatformSelection << " (Wii U)" << endl; // INFORM THE USER OF SELECTING WII U.
    break;
    default: 
    cout << "Please make a valid selection (1,2, or 3)." << endl; 
    }
    } while(UserPlatformSelection < 1 || UserPlatformSelection > 3);

  23. jou nasser Avatar

    i enjoy watching these videos, im not studying anymore

  24. Lucas Chagas Avatar

    New and improved:

    #include <iostream>
    #include <cmath>
    #include <iomanip>

    using namespace std;

    int main()
    {
        float a;
        float p;
        float r;
        int days;

        cout << "Please enter the amount of money being invested: " << endl;
        cin >> p;

        cout << "Please enter the interest rate: " << endl;
        cin >> r;

        cout << "How many days will you be investing? " << endl;
        cin >> days;

        ::cout << ::fixed;

        for(int day = 1; day <=days; day++){
            a = p * pow(1+r, day);

            cout << "Day " << day << " —– $" << ::setprecision(2) << a << " Earned: " << a-p << endl;
        }

        return 0;
    }

  25. Ha Zeke Avatar

    how can you compile without typing return 0??

  26. Rohan Mahajan Avatar

    Is it not same as while loop??

  27. Thetis Stone Avatar

    is there a do for loop?

  28. Marcos Ferreira Avatar

    You have always said  "Pretty cool, huh!" 😀

  29. Theo Payne Avatar

    YOUR AN EXCELLENT TEACHER DUDEE (Y)

  30. StayCurious Avatar

    The title was below the video. You where wrong, Bucky. You where wrong.

  31. MeanNganGuy Avatar

    "SO GET OVER IT"  !!!!   >:(

  32. ero0k Avatar

    like-subscribe – op <3

  33. Bachem Avatar

    You explain better than my dumb teacher, thanks bro!

  34. Neil Roy Avatar

    "You don't want to use it that often"… probably not a good statement.  I would rather state that you only want to use it when you want the code inside of it to run at least once.  Which I know you explained, but that statement saying you don't want to use it that often, just doesn't make much sense.  Like any other function, it depends on what you need your program to do. 

  35. airjamesx Avatar

    your the stupid fucker i ever met that doesnt have to do with anything useful

  36. blind guy suck at gaming Avatar

    bucky should give us homework

  37. Scynder Avatar

    i cant get over it ;(

  38. NOTHING Avatar

    this is usefull for a how much marbles are in the jar program where u have to guess the amount of marbles

  39. MrLinkAddict Avatar

    So the do while loop is the same thing as a while loop just that its guaranteed to run at least once?

  40. Akshay Shukla Avatar

    there are people who come to this video and dislike it. Aliens, maybe?

  41. Dibbie Knight Avatar

    Bucky, can the do while loop method be applied and work the same way as try catch? Or will it still need to catch the errors first before you can even execute the while?

Leave a Reply

Your email address will not be published. Required fields are marked *