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

  Рет қаралды 466,958

thenewboston

thenewboston

Күн бұрын

Пікірлер: 456
@musicignited2725
@musicignited2725 8 жыл бұрын
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!
@beri4138
@beri4138 7 жыл бұрын
Just curious but does learning C++ help with CS?
@lich.possum
@lich.possum 4 жыл бұрын
@@beri4138 the idea is that if you can learn c++ the lowest level language you can learn higher level languages
@Hvidbergen
@Hvidbergen 4 жыл бұрын
@@lich.possum where do you get that idea from? And what do you mean by "lowest level language"?
@samirgunic
@samirgunic 9 жыл бұрын
Just to clarify one thing: the "sentinel" is the "-1" value itself. It's called a sentinel value. It's a special value that controls when to terminate a program, or as in this example: when to step out of the loop. It just so happens that in this example the program ends once he steps out of the loop. But other programs could do other things after this. Hence, "sentinel controlled program". It's not a program controlled by a certain Sci-Fi character if you know what I mean! ;-)
@GizziMoD
@GizziMoD 8 жыл бұрын
+Samir Gunic thx.. I was wondering just this! :)
@nerdii1842
@nerdii1842 3 жыл бұрын
oh cool, thanks for explaining that.
@hetaeramancer
@hetaeramancer 2 жыл бұрын
sentinel vs scourge yun pare
@hetaeramancer
@hetaeramancer 2 жыл бұрын
" a program controlled by a certain Sci-Fi character if you know what I mean! ;-) " dude, seriously? a sentinel controlled program is when a sentinel value controls it. quit messing around and talking about sci-fi characters bro. not cool
@samirgunic
@samirgunic 2 жыл бұрын
@@hetaeramancer no way?! You need to get a sense of humor. Relax, we are not in school here.
@widowdev
@widowdev 6 жыл бұрын
Hey Man. I know this was posted in 2011, and I don't even know if you are active on this channel or not.. but this is really enjoyable to watch. I am taking a condensed 6 week online C++ class at Penn State and yes the book we use is extremely good, but having you think through an example and explain everything is really helpful. I don't have a professor doing that like I normally would in a class like this, all I have is worked out examples in the book - so this gives me that feeling of having a professor to teach me it. Thanks a lot man, appreciate this.
@RCTestKid
@RCTestKid 9 жыл бұрын
Woot. Have watched 20 of your C++ tutorials in 2 days! Aiming to watch 10 a day until I have finished your series!
@lastofthestars6481
@lastofthestars6481 6 жыл бұрын
Really ??
@reshavraj4090
@reshavraj4090 4 жыл бұрын
Mee to @zak
@RCTestKid
@RCTestKid 4 жыл бұрын
@@reshavraj4090 Awesome! (yes I did finish the series)
@reshavraj4090
@reshavraj4090 4 жыл бұрын
@@RCTestKid Any suggestions..for data str and algo.!!
@RCTestKid
@RCTestKid 4 жыл бұрын
@@reshavraj4090 Sorry, I don't know what you're asking.
@chrismavian6194
@chrismavian6194 11 жыл бұрын
I like how he makes everything sound so easy. Something to definitely work towards.
@DeejayAlid
@DeejayAlid 7 жыл бұрын
Nice tutorial, it would have been great if you gave us exercises at the end of each video, thanks for the tutorials.
@theseangle
@theseangle 4 жыл бұрын
@Sourin 2 🤦‍♂️
@muhdsafwan401
@muhdsafwan401 8 жыл бұрын
cout
@kiva8986
@kiva8986 7 жыл бұрын
#include using namespace std: main() { int myAge; cin >> myAge; if (myAge > 1) { cout
@zakariaosman6487
@zakariaosman6487 6 жыл бұрын
its using namespace std; and int main()
@yaboi3749
@yaboi3749 5 жыл бұрын
*RETURN 0;*
@grossio5564
@grossio5564 4 жыл бұрын
@@yaboi3749 yeah you are right........ YA BOI
@sicklaxplayaz
@sicklaxplayaz 13 жыл бұрын
I've noticed a great way to test if you actually learned anything from Bucky's tutorial. Always try to make a program similar to the one that you just made in the tutorial, if you are struggling, go back and watch the tutorial again. This has worked for me, and i just wanted to share it with you.
@WhosTheBossHD
@WhosTheBossHD 9 жыл бұрын
Here's a common practice every coder MUST know. Whenever, you have a variable as your denominator, it is a good idea to make sure that your variable is not 0 (Zero)
@Nightcrawler9001
@Nightcrawler9001 9 жыл бұрын
WhosTheBossHD but if he didn't make total age 0 than it would've been null and u cant add to null
@abird35
@abird35 9 жыл бұрын
+KomodoPanther what he means is that he should've probably added an if (NumberOfPeopleEntered != 0) statement over cout
@CaliforniaGuys916
@CaliforniaGuys916 9 жыл бұрын
This is a very good tip, and I actually ran into this problem while I was in class and couldn't figure out what was going on.
@hetaeramancer
@hetaeramancer 3 жыл бұрын
how the hell could it be 0 though? idiot...
@user-vv9fw7ok9d
@user-vv9fw7ok9d 3 жыл бұрын
@@hetaeramancer Understand what he is saying before insulting him! In case the first input is -1 then the program terminates with numberOfPeopleEntered = 0. Now I wonder who is the idiot...
@NA-is2oo
@NA-is2oo 6 жыл бұрын
your 360p quality recorder is actually so satisfying like everytime i switch back to the video after i finished a line of code you demonstrated. im actually happy
@PapoochCZ
@PapoochCZ 11 жыл бұрын
You can set a new variable to any number if you're about to do calculations with it immediately. If you're gonna assign a value to it later, (e.g. via keyboard input) you can just declare it -> allocate a space in the memory for that variable but it won't have any specific value. (if you try to call it, bad things can happen)
@RoxusRemo
@RoxusRemo 8 жыл бұрын
guys keep clicking onto each concurrent video every second and you get a really cool mix of "hows it goin guys"
@zeustheboerboel3794
@zeustheboerboel3794 8 жыл бұрын
ads!!
@Ele20002
@Ele20002 8 жыл бұрын
adblock!!
@hbv8560
@hbv8560 8 жыл бұрын
Don't use adblock on his vids, this is his income...
@felixruiter3354
@felixruiter3354 2 жыл бұрын
This was much more entertaining than I thought it'd be
@emmanuelhjg69
@emmanuelhjg69 13 жыл бұрын
When you declare your variables, always set it to 0 because it can get random values if you don't
@carlgauss8879
@carlgauss8879 8 жыл бұрын
And on Bucky's 20th tutorial, I finally found out about AD Block Plus for KZbin's beyond obnoxious amount of ads. Life is beyond amazing.
@TakingItCasual
@TakingItCasual 13 жыл бұрын
I was tinkering with the last tutorial and made something that allowed the user to decide how many numbers they wanted involved, but this looks like it gives more options. Time wasted, lessons learned. Love your videos!
@v1e2ridisQ3u4o
@v1e2ridisQ3u4o 12 жыл бұрын
Yes, you can do it that way too. Though, as Bucky mentioned in an earlier tutorial, doubles take up more bytes than an integer, because it's more precise. So in a more complex program where you mainly work with integers but have one or two print-outs or returns which requires decimal precision, a typecast could be a good solution.
@onelerv1
@onelerv1 13 жыл бұрын
I wish I could subscribe more then once to this channel.. I'm so grateful to bucky, he's taking up his own time to help out with teaching us.. Thanks man I really appreciate all your help!
@v1e2ridisQ3u4o
@v1e2ridisQ3u4o 12 жыл бұрын
Yes, you can do it the other way around too to round decimal point types like floats and doubles to integers by putting (int) before the variable.
@miguelmartinez1607
@miguelmartinez1607 Жыл бұрын
11 Years Later and still the best tutorials! Thank you! Also would have taken this opportunity to teach ageTotal+=age; instead of ageTotal = ageTotal +age;
@NALDstudio
@NALDstudio 11 жыл бұрын
Somewhere in the code, (line 22), we can notice that we divide the variable ageTotal by numberOfPeopleEntered. This means that if you type -1 immediately when the program launches, the numberOfPeopleEntered still contains the value of 0 as it is the default value. By realising that the fact dividing any number by 0 causes an equation that doesn't exist, it's simple to understand why the program crashes. By putting a condition that numberOfPeopleEntered must be different from 0, we're okay. :)
@blazingredgaming7377
@blazingredgaming7377 11 жыл бұрын
int numberOfPeopleEntered can be shortened to int nope
@george18almonte
@george18almonte 6 жыл бұрын
I put numberOPE
@coows
@coows 6 жыл бұрын
You mean string numberOfPeopleEntered = "nope" Because you can put words into int, but it's better to put it into a boolean or a string. Really, it's that simple. Try subtracting int "1" and boolean "1" and it wont work. (boolean for short is bo)
@SetYourHandle3
@SetYourHandle3 9 жыл бұрын
I love all your work Bucky. Thank you for making these tutorials :).
@shyamsrinivassportive9182
@shyamsrinivassportive9182 2 жыл бұрын
Man, what are you? You are teaching way more better than many paid tutors. You deserve more than this
@JackMcCrackenOtt
@JackMcCrackenOtt 13 жыл бұрын
Bug: entering negative 1 for the first value causes division by zero (0/0) because both ageTotal and numberOfPeopleEntered are initialized to zero. You could fix it by making a if statement after the first cin read testing if the age variable is equal to -1 and simply returning zero if so.
@Skorbeen
@Skorbeen 8 жыл бұрын
Bucky, you promised at least 1 bad joke per video. You did this many videos back. I think you are russian your videos. On a more serious note, thank you so much man. I've been trying to find a good source to get into programming, you explain things very clear and I'm amazed with what I've built in just a couple of days with your help. Looking forward to watching the rest of your videos:) Cheers!
@NALDstudio
@NALDstudio 11 жыл бұрын
To solve the -1 problem, you need to add a if condition before dividing by the number of people. As numberOfPeopleEntered = 0 when you type -1 at the begenning, it causes a division by 0, which is impossible. if(numberOfPeopleEntered != 0){ cout
@NALDstudio
@NALDstudio 11 жыл бұрын
None of our suggestions is wrong actually. Both are very simple to type and to understand.
@d3lt4X
@d3lt4X 5 жыл бұрын
Using your code, if you type -1 to quit when it asks you to set the first age, it's not going to work as expected. ageTotal and numberOfPersonEntered will be 0 because we've never entered the loop 0 divided by 0 = crash
@diedie111590
@diedie111590 5 жыл бұрын
who cares? you're quitting the program...
@markandrewmoran4398
@markandrewmoran4398 3 жыл бұрын
Sir i can't thank you enough fir making C++ learning easy, and I hope you continue to help people who wants to become a good programmer like you. Btw What App do you use for programming,
@nomevic
@nomevic 9 жыл бұрын
to make sure that the program don't goes crazy if the first number you enter is -1, throw there an If statement too: int main() { int age; int ageTotal = 0; int nrOfPpl = 0; cout age; while(age != -1){ //this make the program stop when -1 is entered ageTotal += age; nrOfPpl++; cout age; } cout
@MoNeyAssasin
@MoNeyAssasin 8 жыл бұрын
why ageTotal += age instead of ageTotal + age?
@matthewnaylor5894
@matthewnaylor5894 8 жыл бұрын
ageTotal = ageTotal + age; is the same as: ageTotal += age;
@saurabhs4743
@saurabhs4743 6 жыл бұрын
Victor Popescu if is by default check Ed in while loop. it's a while loop not do while :)
@LuharVasGamingOz
@LuharVasGamingOz 11 жыл бұрын
Yeah it can be a bit confusing, i suggest getting a book about the basics of C++, before i started watching bucky's videos i read a book about C++ and it's history and it was all so clear to me :)
@williamgrove9617
@williamgrove9617 7 жыл бұрын
I think at this point it would be good to cover error handling! Especially when working with inputs!
@TheCosmicChicken
@TheCosmicChicken 12 жыл бұрын
"And you need to...watch more'v of my videos or something, I dunno'." Quite the sales pitch there, Bucky!
@dibbiepk
@dibbiepk 12 жыл бұрын
After watching this video, I made some common mistakes when I tried it, heres my 2 mistakes I made: int number; - I didnt add = 0; cout >> "Enter first persons age or -1 to quit"
@metznimbo29
@metznimbo29 13 жыл бұрын
@Starcraft2Rogue he will be doing that, he said in the description of his last "Buckys C++ Tutorials" series(#73)
@ThePhil652
@ThePhil652 11 жыл бұрын
at the beginning ageTotal shout be = to 1 because when you want to quit you enter -1 if you ad cout
@chrismavian6194
@chrismavian6194 11 жыл бұрын
No. The number of people entered is how many people you are including in your loop. The age total++ is adding the actual age each time a new person is introduced to your loop. Hope that helps.
@leo-rq2ei
@leo-rq2ei 8 жыл бұрын
while(theNewBoston == good tutorials){ cout
@1kalekip1
@1kalekip1 8 жыл бұрын
Leandro Im gettng a parse error. Pls help!
@leo-rq2ei
@leo-rq2ei 8 жыл бұрын
+Kale Kip you have to create 2 variables: int theNewBoston =100; int goodTutorials =100; while(theNewBoston == goodTutorials){ cout
@1kalekip1
@1kalekip1 8 жыл бұрын
Leandro :)
@sophieeeee3
@sophieeeee3 8 жыл бұрын
You crashed my command prompt goddammit.
@coows
@coows 6 жыл бұрын
Upgrade your computer to a dual core
@sriramiyer7504
@sriramiyer7504 11 жыл бұрын
the program will never end
@constantinmanea5481
@constantinmanea5481 3 жыл бұрын
I really like this guy!! He convinced me to start learning C++ The first video in the list when he say`s Hello "C-nts" killed me I was like , yeah this is where i need to start :)) very well explained, good examples and straightforward!
@commentor5624
@commentor5624 8 жыл бұрын
Instead of using ageTotal=ageTotal+age, you can use the compound operator ageTotal+=age.
@v1e2ridisQ3u4o
@v1e2ridisQ3u4o 12 жыл бұрын
You do get a rounding error with this, for example putting 10 and 11 you should get the average 10.5, however it outputs 10. Putting a (float) before ageTotal/numberOfPeopleEntered; you get a few decimals
@vulpine678
@vulpine678 5 жыл бұрын
thank u so much... the explanation is clear and straightforward...
@rohithaider
@rohithaider 6 жыл бұрын
Best tutorials ever! I love the way you Mr. BUCKY!
@TheProjekton
@TheProjekton 9 жыл бұрын
nPeople It's known throughout programming that using "n" means "number of".. nPeople = numberOfPeople nRedApples = numberOfRedApples etc etc
@mockingbird3809
@mockingbird3809 7 жыл бұрын
In this program first itself is we entered -1 means the code blocks will hang, cheak it out with same command that Bucky shown
@MarijnKonings
@MarijnKonings 11 жыл бұрын
No idea, a double or a float would indeed be better in this case for the result. The amount of people entered wouldn't really need a decimal number since it will always increment by 1.
@LuharVasGamingOz
@LuharVasGamingOz 11 жыл бұрын
They are integer values so no they don't have to be positive. As long as they are whole numbers (meaning that they do not contain decimals) it should be fine :)
@dibbiepk
@dibbiepk 11 жыл бұрын
Holy crap this is gon be a big bonus for me next week... Thanks Bucky
@NikorasuChan
@NikorasuChan 12 жыл бұрын
I learnt few programming languages beforehand ;) && is means 'and', for example if there two variable, and you want to check whether both variables is equal to the value you want, and if both returns the value that you want, for example, you wanted variable a to return 1 and b to return 0, by using if (a==1 && b==0), you can then put in the code in the { } and blah blah blah... eventhough I dont know if I'm answering you XD
@bbszn
@bbszn 11 жыл бұрын
To get exact average, he would need to do ageTotal from "int" to double or float. And, I think, he would need to do "Average age"(line 22) an variable, which type would be double or float. Then he would get an exact average.
@breenud39tv
@breenud39tv 4 жыл бұрын
I have a question, I tried entering 10000000000 just as a joke to see what would happen then it infinitely loops what I had in cout. How do I prevent that? Like how would I add a limit for age lets say so no one is allowed to enter such high numbers?
@muhammadhadad8185
@muhammadhadad8185 7 жыл бұрын
Amazing! Love your lecture sir!
@NeilRoy
@NeilRoy 10 жыл бұрын
So if I enter -1 right away without entering any ages at all, what happens? You should always check for errors, test everything, make certain number of people entered and the total ages are both positive values. You should also check for proper values when they are input, perhaps in a range from 1 - 120. Get in the habit of checking all return values and testing everything.
@Qazqi
@Qazqi 11 жыл бұрын
Dividing by 0 is undefined behaviour; it doesn't have to crash.
@dhruvkhetrapal4279
@dhruvkhetrapal4279 9 жыл бұрын
We could just take input from user for the no of persons.Then accordingly run the loop.
@PipleKlo
@PipleKlo 6 жыл бұрын
Can't you add cout
@makegamestv247
@makegamestv247 8 жыл бұрын
In what case would you prefer to use a sentinel value over... say a string input like "quit"? I haven't followed your other tutorials, so you may have already covered this.
@makegamestv247
@makegamestv247 8 жыл бұрын
+Peterolen Yes. I was under the assumption a sentinel "value" had to be a number. Since then I learned that's not the case.
@AdpoGamer
@AdpoGamer 11 жыл бұрын
Thank you so much for this tutorial! It has helped me a lot :D
@dibbiepk
@dibbiepk 11 жыл бұрын
Thats because when the program first starts, the user hasnt entered anyone yet, so after they enter someone that value will be 1, and when they enter the next person it will be 2, and so on and so on, but it starts at 0, because they didnt enter any one yet, so its value is 0
@TheUntamedNetwork
@TheUntamedNetwork 11 жыл бұрын
hey, i didnt want it to attempt to work out averages if you quit immediately so before the the loop i added a if (age==-1){return 0} in this example it works perfect but i was wondering if it would trip me up on bigger projects?
@jigarlush6429
@jigarlush6429 8 жыл бұрын
bucky so great bro you are tutorial it's make me fun i mean i got you more than my lecture
@xetrius3671
@xetrius3671 9 жыл бұрын
You didn't account for the user wanting to quit before entering an age. For those who got an error because they entered -1 before entering an age, you can solve this with a simple test to check if the amount of ages entered is bigger then 0. For example: #include using namespace std; int main() { int age; int ageTotal = 0; int people = 0; cout age; while(age!=-1){ ageTotal += age; people++; cout age; } if(people != 0){ cout
@Qazqi
@Qazqi 11 жыл бұрын
0/0 is indeterminate. Positive or negative numbers divided by 0 are undefined.
@george18almonte
@george18almonte 6 жыл бұрын
I literally love you dude
@imamuddin8042
@imamuddin8042 4 жыл бұрын
You could start with age = 0 and take your first cout and cin inside the loop. And with that, you dont need to put again cin >> age at the end of loop.
@imamuddin8042
@imamuddin8042 4 жыл бұрын
Sorry my bad, in that case, first iteration of loop would always happen and it might take invalid -1 as input and will return invalid average -1
@intensity67
@intensity67 13 жыл бұрын
Hey Bucky, sorry for this annoying interruption for a little bug but you forgot that if the user puts only 1 age in this program it'll cause wrong output i in the computation of age and number of people... the onlyway to fix this is to put the numberofPeopleEntered++ above the loop also...
@BiscuitTech
@BiscuitTech 12 жыл бұрын
@kojax98 That's because one of "Age" has a capital letter and the other hasn't. Make them both identical and it's gonna work.
@dkblade27
@dkblade27 10 жыл бұрын
Bucky forgot to type cast the average part. Int divided by int only gives int but the average can be a decimal value. So remember to type cast.
@yagamilul4479
@yagamilul4479 4 жыл бұрын
i just love the number 5
@P4INKiller
@P4INKiller 12 жыл бұрын
Yup, anytime you specify one type of data as another datatype.
@ClaudiuB
@ClaudiuB 7 жыл бұрын
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?
@Kats072307
@Kats072307 8 жыл бұрын
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
@Impulse_Photography
@Impulse_Photography 5 ай бұрын
I think, you should have use zero instead of (-1) to cause the loop to quit. Otherwise, if someone entered zero then it will do the division by zero, which could cause program to crash.
@dre38w
@dre38w 13 жыл бұрын
@Rigardoful haha That works too. Making the numOfPeeps an unsigned int works a LOT better than my order of operations take on it.
@heejeongjeong4881
@heejeongjeong4881 8 жыл бұрын
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 using namespace std;int main(){ int age; int agetotal = 0; int numberofpeople = 0; while(age!=-1){ cout age; agetotal = agetotal + age; numberofpeople++; } cout
@edwarlkd814
@edwarlkd814 12 жыл бұрын
If we want to make the function the other way, would it better to use Void function or Value returning funcition? Value returning funciton as in like make it as separate function outside the main?
@Moon_Rose달장미
@Moon_Rose달장미 4 жыл бұрын
highlights: 1. ik i spelt it wrong. big deal, who cares 2. enter big numbers like 86, 68, 5 and yeah all those. like 5's a big number (,duh!)
@niceheadcrab34225
@niceheadcrab34225 11 жыл бұрын
You can divide by zero. A positive number divided by zero is infinity; a negative is negative infinity. I forgot what zero divided by zero was.
@xTxNarutoxTx
@xTxNarutoxTx 12 жыл бұрын
I've rarely seen ads, if any at all on his videos o.o. I hope he does make money from these, he definitely deserves a lot. I bet people are passing computer science like nothing because of Bucky. If he is a millionaire he deserves it :D.
@MrZiglu
@MrZiglu 9 жыл бұрын
so we are not having the first person age in a while loop, because we just want to write that is first one? and the first incremenation and ageTotal +=age is connected with that cin above the loop :) ?
@josephnasr3385
@josephnasr3385 8 жыл бұрын
thank you for this video 😁😁 but may I ask why did you initialize the two variables "ageTotal" and "numberofPeopleEntered" and you didn't keep it without the "=0" like you did with "age"??
@MAlicechan
@MAlicechan 8 жыл бұрын
It's probably because age is the only variable that takes input from the user. You can not use operations on variables that do not have an initial value in the memory (thus we usually initialize it with 0). If you try the same code and remove the =0, the compiler will give you an error
@josephnasr3385
@josephnasr3385 8 жыл бұрын
Nyancatreturns ohhh okay you are right I tried it. Thanks a lot :)
@MAlicechan
@MAlicechan 8 жыл бұрын
glad to help :3
@rayzecor
@rayzecor 8 жыл бұрын
That is not true actually.
@pragatiranjan9418
@pragatiranjan9418 3 жыл бұрын
in my program no.of pepole entered is always showing the actual value increased by one
@NoName-oq8ok
@NoName-oq8ok 8 жыл бұрын
thaaaaaaaaaaaaaaaaaaaaaaaanks finally i got it
@odo432
@odo432 11 жыл бұрын
Modified this program using only what we have learned to get number of people, total age of people, oldest person, youngest person, and average age of people entered.
@JoshRenton91
@JoshRenton91 11 жыл бұрын
If you use numbers that don't average to integers it doesn't give you the decimal. When do we learn about floating points? Cheers, your videos are awesome
@cmvisuals9182
@cmvisuals9182 6 жыл бұрын
Thank you. 👏👏 October 2018
@RobertHovakimyan55
@RobertHovakimyan55 10 жыл бұрын
My families average age is 28! Thank You, I always was curious...
@baqerghezi1342
@baqerghezi1342 4 жыл бұрын
you don't need to initialize the variables if you use (do - while) loop
@Binary10100
@Binary10100 11 жыл бұрын
That's because they're ints. If you wanter higher numbers, use longs.
@NALDstudio
@NALDstudio 11 жыл бұрын
Also, I was trying to show the source of the problem inside the code, which was caused by the division by zero so my example was better to explain the solution to that problem.
@RedsBoneStuff
@RedsBoneStuff 9 жыл бұрын
2:34 Or "nope" in short :3
@lindio95
@lindio95 10 жыл бұрын
Why when i enter a number the NumberofPeopleEntered is going to be 1 and no 0 ? NumberOfPeopleEntered its strart to 0 end is NumberOfPeopleEntered++ not ++NumberOfPeopleEntered sow at first hes value is 0 right ? Sorry for my bad english , Pls help.
@Owlserker
@Owlserker 7 жыл бұрын
When i type -1 to get the average when i open the .exe after putting in some numbers the console closes. how do i say no to that?
@arturbella2544
@arturbella2544 11 жыл бұрын
I'm the rainmaker, i'm closing all the loops.
@RudeProdigy
@RudeProdigy 10 жыл бұрын
Thank you!!!!! Really helpful!!!
@dibbiepk
@dibbiepk 11 жыл бұрын
If I am understanding right ur problem is: It adds ur 5 numbers u enter, and thats it, doesnt display anything? If thats true, ur solution is: First, check ur code for typos, if none: Have it add the numbers, then store those numbers in ageTotal, then display to the user, like this: cout
@mohammadashhar3916
@mohammadashhar3916 7 жыл бұрын
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?
@joelsanchez3250
@joelsanchez3250 6 жыл бұрын
Bucky is a great speller !!!! "Number of peoople eneted !!!! "
@MrEpicSpace
@MrEpicSpace 10 жыл бұрын
type -1 on first input and it should crash.
@AntiAnathema
@AntiAnathema 10 жыл бұрын
Because at the end of the programme it is still trying to divide by 0.
@berrymckokinger9317
@berrymckokinger9317 6 жыл бұрын
If you entered -1 on first input,the output would be the two cout statements......smh
@poinpchu
@poinpchu 6 жыл бұрын
Patch fix 1.1 if(numberOfPeopleEntered == 0) { cout
@mitigamespro8757
@mitigamespro8757 6 жыл бұрын
What about this one: (I know it's a different subject.) #include using namespace std; int main() { int classnumber; int x=1; int number; int total=0; cout > classnumber; cout
@leaper7808
@leaper7808 4 жыл бұрын
You can fix that by doing a pre-check. if (numPeople == 0 && age == -1) { return 0; } This way the program will exit safely without a crash.
Don't look down on anyone#devil  #lilith  #funny  #shorts
00:12
Devil Lilith
Рет қаралды 48 МЛН
Friends make memories together part 2  | Trà Đặng #short #bestfriend #bff #tiktok
00:18
Flipping Robot vs Heavier And Heavier Objects
00:34
Mark Rober
Рет қаралды 59 МЛН
Всё пошло не по плану 😮
00:36
Miracle
Рет қаралды 3,5 МЛН
Buckys C++ Programming Tutorials - 18 - while Loops
6:10
thenewboston
Рет қаралды 641 М.
Buckys C++ Programming Tutorials - 17 - if / else Statement
7:02
thenewboston
Рет қаралды 589 М.
Buckys C++ Programming Tutorials - 9 - Functions
9:04
thenewboston
Рет қаралды 1,2 МЛН
Buckys C++ Programming Tutorials - 8 - if Statement
7:15
thenewboston
Рет қаралды 749 М.
Buckys C++ Programming Tutorials - 19 - Simple Program Using a Loop
7:44
Buckys C++ Programming Tutorials - 13 - Using Variables in Classes
9:12
thenewboston
Рет қаралды 1,1 МЛН
Don't look down on anyone#devil  #lilith  #funny  #shorts
00:12
Devil Lilith
Рет қаралды 48 МЛН