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

Buckys C++ Programming Tutorials – 20 – Sentinel Controlled Program
by
Tags:
Comments
46 responses to “Buckys C++ Programming Tutorials – 20 – Sentinel Controlled Program”
-
is he ever answering or commenting on anything?
-
I just wonder what would happen if you entered other negative numbers (like -2 or -n) ?
-
Amazing!
Love your lecture sir! -
Does anyone know what font he is using?
-
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;}
-
I don't know. I just like five.
-
+thenewboston
AGE AVGR.5.0 ….why 5.0 ?? i dunno i just like 5 😛 😛 😛 -
Missed a chance to use a function to input the ages
-
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. -
In this program first itself is we entered -1 means the code blocks will hang, cheak it out with same command that Bucky shown
-
Bucky, are u an alien?
-
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?
-
I think at this point it would be good to cover error handling! Especially when working with inputs!
-
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?
-
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.
-
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.
-
Nice tutorial, it would have been great if you gave us exercises at the end of each video, thanks for the tutorials.
-
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 ? -
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? -
#include <iostream>
using namespace std;
int main()
{
cout << "Bucky is the best" << endl;
return 0;
system("Pause");
} -
cout << "Bucky is the best programming teacher/homie ever." << endl;
-
#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";
}
}
} -
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;
} -
Is there any different if I put numberOfPeopleEntered++ aftercin age inside the loop? I wish anybody answers me.
-
9:29 Could this explain why you named your project Watermelon? 😉
-
love you bucky :3 because of you i am earning so much and i have a great job! you are a life changer thanks!
-
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.
-
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;
} -
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.
-
Go Down |
|
V
_ _ __ __ __ _ _
|_ _| | | / _ / / | __| / ___|
| | | |__| | () V / | _| | (__ ++
|___| |____| ___/ _/ |___| ____| -
Number of people should start counting from 1. So, shouldn't we set y=1?
-
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 -
wow..its getting harder
-
anyone else accidentally get it to divide by zero by immediately typing -1?
-
Instead of using ageTotal=ageTotal+age, you can use the compound operator ageTotal+=age.
-
Who said that C++ is hard!!!
-
#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");
} -
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
-
"Eneted"
-
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
-
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!
-
why did mine turn out infinity of the "Enter the next age or -1 to quit" T___T
Im very sure i copied exactly… -
bucky you mind if i use some of your Tutorials in my streams,thank you bro..and keep up the good work
-
thaaaaaaaaaaaaaaaaaaaaaaaanks finally i got it <3 <3
-
while(theNewBoston == good tutorials){
cout<<"great video!"<<endl;
} -
In class, in youtube they just teach the easy things and in exams what the fuck happens ! fucking hell !
Leave a Reply