Buckys C++ Programming Tutorials – 20 – Sentinel Controlled Program

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


Posted

in

by

Tags:

Comments

46 responses to “Buckys C++ Programming Tutorials – 20 – Sentinel Controlled Program”

  1. bujashaka Avatar

    is he ever answering or commenting on anything?

  2. Youssef EL assaad Avatar

    I just wonder what would happen if you entered other negative numbers (like -2 or -n) ?

  3. Muhammad Hadad Avatar

    Amazing!
    Love your lecture sir!

  4. Bryan Rincon Avatar

    Does anyone know what font he is using?

  5. Bien-Aime Keit n 'ke Avatar

    mine did not get it right

    #include <iostream>
    using namespace std;

    int main()
    {

    int age;
    int total = 0;
    int numberEn =0;

    cout << "enter age or -1 to quit "<<endl;
    cin>> age;

    while (age !=-1){

    total = total + numberEn;
    numberEn++;
    cout<< "next person age"<<endl;
    cin >>age;

    }

    cout << "the number en is"<<numberEn<<endl;
    cout <<" the age averge is"<< total/numberEn<<endl;

    }

  6. Piotr Michalski Avatar

    I don't know. I just like five.

  7. retail king Avatar

    +thenewboston
    AGE AVGR.5.0 ….why 5.0 ?? i dunno i just like 5 😛 😛 😛

  8. fablanta Avatar

    Missed a chance to use a function to input the ages

  9. Gaming Turkey Avatar

    Most of your C++ tutorials are actually C tutorials.
    Since you made a separate playlist for C tutorials, I was hoping you would focus solely on C++ in this playlist.
    I'm a little disappointed with how half of this playlist is just a rerun of C. Still going to watch all of it though.

  10. Harsath Bill Gates Avatar

    In this program first itself is we entered -1 means the code blocks will hang, cheak it out with same command that Bucky shown

  11. Jack Claudiu Avatar

    Bucky, are u an alien?

  12. Jack Claudiu Avatar

    Well, why I get a windows error if I enter from the beginning -1. Maybe I hit compile&Run by mistake and wanna quit the program, not enter the age of ppl ? Because it doesn't enter the loop and I already pressed -1? How can we fix this?

  13. William Grove Avatar

    I think at this point it would be good to cover error handling! Especially when working with inputs!

  14. MegaRandall2011 Avatar

    I''m trying to change the code so the user enters q for quit rather than -1 with no luck. Any help? I have a feeling I need to add a new variable? Anyone?

  15. Shaun Mills Avatar

    A more efficient way of doing it:

    #include <iostream>
    using namespace std;

    int main()
    {
    int age = 0;
    int pCount = 0;
    int totAge = 0;
    int avAge = 0;

    while (age != -1)
    {
    cout << "Enter age or -1 to quit: ";
    cin >> age;
    totAge = totAge + age;
    pCount++;
    }

    avAge = totAge / pCount;

    cout << "Number of people entered: " << pCount << endl;
    cout << "Average age: " << avAge;

    return 0;
    }

    //By setting age to 0 when creating the variable, the loop starts without having to get user input, therefore no repeated lines of code.

  16. creativeKnowledge Mike Avatar

    I did something wrong , i think i hit a wrong button now past calculations are showing on too these new ones. not sure whats going on.

  17. DeejayAlid Avatar

    Nice tutorial, it would have been great if you gave us exercises at the end of each video, thanks for the tutorials.

  18. MJ Sanchez Avatar

    Buckey,
    What if the user enters -2 or -3, then the ageTotal will be decremented by 2 or 3.
    Is that what you want to do ?

  19. Mohammad Ashhar Avatar

    when we enter int agetotal= 0; and int numberofpeopleentered= 0;
    How does the Program know which one is total and which one is number of people entered?

  20. Raitik MKD Avatar

    #include <iostream>

    using namespace std;

    int main()
    {
    cout << "Bucky is the best" << endl;
    return 0;
    system("Pause");
    }

  21. MathRed Avatar

    cout << "Bucky is the best programming teacher/homie ever." << endl;

  22. MathRed Avatar

    #include <iostream>

    using namespace std;

    int main() {

    int x, y, sum, diff, product, quotient, reminder, decision;
    decision = 10;
    cout << "I'm a calculator. Do you want to find a maths answer?n";
    cout << "Type '1' for addition, '2' for substraction, '3' for multiplication or '4' for division.n";
    cout << "Type '5' to quit.n";
    while (decision != 5) {
    cin >> decision;
    if (decision == 1) {
    cout << "Type your first addend.n";
    cin >> x;
    cout << "Type your second addend.n";
    cin >> y;
    sum = x + y;
    cout << "The sum is " << sum << ".nn";
    }

    if (decision == 2) {
    cout << "Type your minuend.n";
    cin >> x;
    cout << "Type your subtrahend.n";
    cin >> y;
    diff = x – y;
    cout << "The difference is " << diff << ".nn";
    }

    if (decision == 3) {
    cout << "Type your multiplier.n";
    cin >> x;
    cout << "Type your multiplicand.n";
    cin >> y;
    product = x * y;
    cout << "The product is " << product << ".nn";
    }

    if (decision == 4) {
    cout << "Type your dividend.n";
    cin >> x;
    cout << "Type your divisor.n";
    cin >> y;
    quotient = x / y;
    reminder = x % y;
    cout << "The quotient is " << quotient << " while the remainder is " << reminder << ".nn";
    }

    if (decision == 5) {
    cout << "Thanks for using this program!";
    return 0;
    }
    if (decision > 5) {
    cout << "That is an invalid number. Valid numbers are 1, 2, 3, 4 and 5.nn";
    }
    }
    }

  23. Mister Fihen Avatar

    This program calculates every day's profit and total profit 😀

    #include <iostream>
    #include <cmath>
    using namespace std;

    int main ()
    {
    int total = 10000;
    int profit ;
    int totalprofit = 0;
    for (int day = 1; day <= 10; day++ ){
    total = total + total * 0.01 ;
    profit = total + total * 0.01 – total ;
    cout << "Day " << day << " Profit : " << profit << endl;
    totalprofit = totalprofit + profit;
    }
    cout << "Total Profit is : " << totalprofit << endl;
    }

  24. Aya Avatar

    Is there any different if I put numberOfPeopleEntered++ aftercin age inside the loop? I wish anybody answers me.

  25. Samir Gunic Avatar

    9:29 Could this explain why you named your project Watermelon? 😉

  26. I Learn Avatar

    love you bucky :3 because of you i am earning so much and i have a great job! you are a life changer thanks!

  27. DustAlbatross Avatar

    I'm at the 30th tutorial now but there is one thing I haven't figured out how to do with the code in this video. How can I make it so that instead of putting in -1 to calculate I can type in "average" instead of an age value to calculate? Great tutorials btw.

  28. HEEJEONG JEONG Avatar

    Thx for amazing class! i have a question as a super beginner, I watched the tutorial 20 n compile&run the same, and worked well. then i wanted to try put first person into the loop, so I made the below. but it is calculating -1 to the average… could you tell me why it isn't working?#include<iostream>
    using namespace std;int main(){
     
     int age;
     int agetotal = 0;
     int numberofpeople = 0;
     
     
     while(age!=-1){
        cout << "enter person's age or -1 to quit" << endl;
     cin >> age;
     agetotal = agetotal + age;
     numberofpeople++;
    }
     
     cout << "numberofpeople entered : " << numberofpeople << endl;
     cout << "average age : " << agetotal/numberofpeople << endl;
     
     
     return 0;
     
    }

  29. Carl Gauss Avatar

    And on Bucky's 20th tutorial, I finally found out about AD Block Plus for YouTube's beyond obnoxious amount of ads. Life is beyond amazing.

  30. Andi Basha Avatar

    Go Down |
    |
    V
     
    _ _ __ __ __ _ _
    |_ _| | | / _ / / | __| / ___|
    | | | |__| | () V / | _| | (__ ++
    |___| |____| ___/ _/ |___| ____|

  31. Abjo Das Avatar

    Number of people should start counting from 1. So, shouldn't we set y=1?

  32. Kats072307 Avatar

    4:07 How can I type just the first few letters and make the POSSIBLE variables be displayed ? In this case it was the huge variable numberOfPeopleEntered 🙂
    I'm also using CodeBlocks on a Macbook

  33. Banana Bux Avatar

    wow..its getting harder

  34. Jack Avatar

    anyone else accidentally get it to divide by zero by immediately typing -1?

  35. Commentor Avatar

    Instead of using ageTotal=ageTotal+age, you can use the compound operator ageTotal+=age.

  36. Dark Shadow Avatar

    Who said that C++ is hard!!!

  37. Ivan Nikitin Avatar

    #include <iostream>
    #include <cstdlib>
    using namespace std;

    int main() {
    int age;
    int sumAge=0;
    int PeopleCount=0;

    cout << "Enter first persons age or -1 to quit n";
    cin >> age;
    if (age == -1) {
    exit(EXIT_SUCCESS);
    }
    else {
    while (age != -1) {
    sumAge = sumAge + age;
    PeopleCount++;
    cout << "Next Person Age or -1 to quit" << endl;
    cin >> age;
    }

    }
    cout << "Number of people is " << PeopleCount << endl;
    cout << "Average age is " << sumAge / PeopleCount << endl;
    system("PAUSE");
    }

  38. atomicasshole Avatar

    i am using tow inputs one that has nothing to do with program that we created but one does the firs input which has nothing to do with program screws it up and makes it run multiple times because it is going of that

  39. hari prasad Avatar

    after compiling i got int value for avg of ages……….even though i declared it as floating point number?????? y is this happening……can any one answer me plzzzzzzzzzzzzz

  40. Music Ignited Avatar

    Dude, I swear you have a way of teaching C++ so simply and understandable! I take 45 mins of CS class and I'm still left in confusion on certain topics, thank you so much for investing your time to do these tutorials!

  41. Ana Xiu Avatar

    why did mine turn out infinity of the "Enter the next age or -1 to quit" T___T
    Im very sure i copied exactly…

  42. charley rose Avatar

    bucky you mind if i use some of your Tutorials in my streams,thank you bro..and keep up the good work

  43. Aseel Omar Avatar

    thaaaaaaaaaaaaaaaaaaaaaaaanks finally i got it <3 <3

  44. le00 Avatar

    while(theNewBoston == good tutorials){
    cout<<"great video!"<<endl;
    }

  45. Ahtasam Culé Avatar

    In class, in youtube they just teach the easy things and in exams what the fuck happens ! fucking hell !

Leave a Reply

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