C++ Program to Count Number of Consecutive Inputs

  Рет қаралды 56,422

Neso Academy

Neso Academy

Күн бұрын

Пікірлер: 58
@chester0415
@chester0415 2 жыл бұрын
You have a great great stamina teaching every single thing so precisely.
@chester0415
@chester0415 2 жыл бұрын
Sir i understood everything you said.exept the curval=val cnt=1. Inside the else statement.
@СарварбекКабулов-к9я
@СарварбекКабулов-к9я Жыл бұрын
same
@user-qs1ez1ko5f
@user-qs1ez1ko5f Жыл бұрын
That is to ensure the program uses the "else"-case val as its currVal reference point when it loops back to compare with the next std::cin >> val. Otherwise it would continue reading 10 10 8 8 as just 10 10 10 10 because nothing ever changed the currVal stated at the beginning of the script. And count goes back to one to start the count fresh for this new reference number (currVal = 8, ct =1 during the end of the third while loop in my example).
@GammaVideosable
@GammaVideosable 3 жыл бұрын
Thank you, very informative and well explained ! 👍
@LeonardNjuguna-l3b
@LeonardNjuguna-l3b 7 ай бұрын
it was the fist one to pose a challenge, but Thankyou. Perfect explanation
@ledschmidt1441
@ledschmidt1441 11 ай бұрын
Well I've followed several of your programs and they are precise and work well. Your detail is superb.... NOW when it comes to this particular one, I think we should tell the USER, to enter the numbers using the space bar Between entries, if you enter a number then hit the ENTER key, the program gets confused and the numbers go in vertically which we do not want. Ok?
@tayyab.sheikh
@tayyab.sheikh Жыл бұрын
This program is Fine 👍🏽 but we want to know the thought process behind the program, how did you made the logic from scratch. Please make a video on logic building 🙏🏽
@farhanahassan8389
@farhanahassan8389 11 ай бұрын
Read the c++ primer book
@421-r.venkateshnaik7
@421-r.venkateshnaik7 3 жыл бұрын
Anna We need C programme from beginning to end with deep concepts & examples anna.....
@jallipallisaipraveenkumar1801
@jallipallisaipraveenkumar1801 3 жыл бұрын
Fantastic mind blowing unbelievable. Amma Baboi🔥🔥🔥
@gaganpatrobammidi3005
@gaganpatrobammidi3005 2 жыл бұрын
Recordlu theragesthadhi 😀
@touseef_akhtar
@touseef_akhtar 2 жыл бұрын
Why are all the COUTs appearing after entering all the numbers?? Should not it appear as soon as we enter a different number from the previous one as per the code? Please guide
@Martin958
@Martin958 Жыл бұрын
@touseef_akhtar I had the same thought. I could not see why the last numbers would not overwrite the previous ones that are input. But if you watch, he enters all the numbers at the same time on one single input line. That means they all get processed in the while loop as one long feed, hence they do not overwrite one another. So, the while loop can generate a separate message for each group of consecutive numbers, and only stops when you enter an end of file value.
@rajeshprajapati6662
@rajeshprajapati6662 Жыл бұрын
On Stackoverflow : Difference between entering values in cin using spacebar and enter key?
@chester0415
@chester0415 2 жыл бұрын
You are an angle sir.if you war'nt the one teaching than i would have never understood this cause you know i am only 14.
@siddeshwarapm5613
@siddeshwarapm5613 2 жыл бұрын
Best lecture. and defining.
@tadelemesfin2558
@tadelemesfin2558 2 жыл бұрын
Amazing lecture.
@sachinsudaraka6397
@sachinsudaraka6397 3 жыл бұрын
Thanks
@Light13378
@Light13378 Жыл бұрын
Why in second time is not 2 time equals to in currval = val
@batchuamarnathguptha3364
@batchuamarnathguptha3364 3 жыл бұрын
sir please make regular videos on c++
@srinivasaraob2890
@srinivasaraob2890 3 жыл бұрын
It is very difficult to wait for long time sir please make sure that videos are regular . Thank you.
@matbarjoshi7891
@matbarjoshi7891 3 жыл бұрын
yeah same
@chester0415
@chester0415 2 жыл бұрын
It takes a a lot of effort explaining every single thing precisely.
@rajkumarsaraboju1756
@rajkumarsaraboju1756 3 жыл бұрын
Sir please make regular videos on C++
@Pooja-ch1hl
@Pooja-ch1hl 3 жыл бұрын
please make python playlist
@LVC85costa
@LVC85costa 11 ай бұрын
So the first input goes into the if and changes currVal as long as its an int, therefore the if body works. Is that enough to make the cin not update currVal again, because its in the IF? I guess I'm confused as to why the second int input goes into the WHILE that's inside the IF. That's the only part I don't fully get. I am going to look at it for a few more minutes. Thanks for the lesson.
@MohitKumar-kr8wk
@MohitKumar-kr8wk 3 жыл бұрын
Plz make regular video on C++ sir
@sloughpacman
@sloughpacman Жыл бұрын
Good video, buggy program. Of course, you never get the character count for the last entry because the program never identifies it as the last repetition in the sequence, unless an EOF char such as 'a' is used. Returning a sequence of valid numbers alone or ending them with the ^D EOF char on Linux is merely a program interrupt that does not output the sequence count for the final number and terminate the program - you can of course continue entering more valid numbers after the interrupt to get the missing line, but the program then becomes unending and you never get the new final line. This why everyone uses Python for simple programs, because tying up all those loose ends with C++ is only worth it for large complex systems!!! You can experiment with ChatGPT to build a C++ program for the required task, and then have it do the same with Python. The Python code is far, far simpler. I love these almost philosophical discussions about C++ because you can see that by design it is not intended to end and therefore has mostly 'always on' use cases.
@SurajPandey-vi9gr
@SurajPandey-vi9gr 11 ай бұрын
wdym in a nutshell ?
@mohitzen
@mohitzen 3 жыл бұрын
I am unable to print the number of occurrences of the last entry even after writing the cout statement after end of else { }. Please help out.
@陳嘉宇-y4q
@陳嘉宇-y4q 2 жыл бұрын
same goes with me, there's a bug in the code I guess
@rajeshprajapati6662
@rajeshprajapati6662 Жыл бұрын
I had to press Ctrl D two times, one for While loop and another for If condition. After that, everything appears fine.
@rajeshprajapati6662
@rajeshprajapati6662 Жыл бұрын
Did you try on Windows ?
@afanoromolyricsofficial
@afanoromolyricsofficial 2 жыл бұрын
done!
@mohitnamdev7323
@mohitnamdev7323 2 жыл бұрын
i worked out the exact same code you showed but it is not working accordingly: can someone please help: code #include using namespace std; int main() { int cur, val, count; cur=0; val=0; if (cin >> cur) { int count = 1; while (cin>>val) { if (val==cur) { ++count; } else{ cout
@handle_gc
@handle_gc 2 жыл бұрын
You redefined count 2 times
@SurajPandey-vi9gr
@SurajPandey-vi9gr 11 ай бұрын
@@handle_gc that's what the tutor has done
@johnsumith2107
@johnsumith2107 2 жыл бұрын
For storing multiple numbers val should be array right??
@NocturnalCoder022
@NocturnalCoder022 2 жыл бұрын
no it just acts as a buffer element
@AlokSingh-gl6hz
@AlokSingh-gl6hz 3 жыл бұрын
Why ur video come late plz upload video in regular frequency
@malaythakur4380
@malaythakur4380 3 жыл бұрын
please upload video ASAP. please sir.
@nesoacademy
@nesoacademy 3 жыл бұрын
Yes, we’re working on the upcoming lectures.
@malaythakur4380
@malaythakur4380 3 жыл бұрын
@@nesoacademy Thanks ❤️
@mrnavi188
@mrnavi188 3 жыл бұрын
✌🏻sir when we will give input 5 5 5 4 5 6 it will give ouput 5 occures 3 times 4 occures 1 times 5 occures 1 times 6 occures 1 time But sir it isn't adding them 5 consecutive 5 occures 4 times
@nofreewilltakethepill
@nofreewilltakethepill 3 жыл бұрын
5 occurs 3 times consecutively. The other input of five, don't belong to the chain of consecutive fives. I hope I made myself clear
@abhisaragarwal9084
@abhisaragarwal9084 2 жыл бұрын
Do it with array and then itterate it to check with if condition
@NocturnalCoder022
@NocturnalCoder022 2 жыл бұрын
@@nofreewilltakethepill yes, appreciable
@AziaAbdi
@AziaAbdi 5 ай бұрын
Really I don't understand this lesson any help
@bhanupratap-qj4lp
@bhanupratap-qj4lp 3 жыл бұрын
Sir please a request don't provide upcoming videos for cost plz make this complete course free of cost 🙏🙏as I am not able to afford price for 1 month as 200 it's literally high for a single month.This course is need of everyone preparing for interviews of some good companies 🙏🙏
@Kill296
@Kill296 7 ай бұрын
#include using namespace std; int main() { int val=0 , currval=0; int count; if(cin >> currval) { count = 1; while(cin >> val) if (val == currval) { ++count; } else { cout
@xtreameidea3126
@xtreameidea3126 3 жыл бұрын
🔥🔥🔥🔥🔥🔥
@DalandanReal
@DalandanReal 3 ай бұрын
Dude I don't think the outer if condition needs to be there it's unnecessary it confused the people wants to learn
@rajubhai-vf3nk
@rajubhai-vf3nk 2 жыл бұрын
thank you so much sir. but am unable to run this program output get wrong. please help.
@SurajPandey-vi9gr
@SurajPandey-vi9gr 11 ай бұрын
very confusing.
@freewifi8147
@freewifi8147 3 жыл бұрын
liked
@savin8878
@savin8878 3 жыл бұрын
💞💞💞💞💞💞🙏
@farhanahassan8389
@farhanahassan8389 11 ай бұрын
These videos are all copied from the C++ primer book. Sad, very sad.
Indentation and Formatting of C++ Programs
12:04
Neso Academy
Рет қаралды 39 М.
Signed and Unsigned Types in C++
14:46
Neso Academy
Рет қаралды 85 М.
БАБУШКА ШАРИТ #shorts
0:16
Паша Осадчий
Рет қаралды 4,1 МЛН
요즘유행 찍는법
0:34
오마이비키 OMV
Рет қаралды 12 МЛН
Вопрос Ребром - Джиган
43:52
Gazgolder
Рет қаралды 3,8 МЛН
Reading an Unknown Number of Inputs in C++
12:59
Neso Academy
Рет қаралды 64 М.
why do void* pointers even exist?
8:17
Low Level
Рет қаралды 400 М.
Primitive Built-in Types in C++
14:57
Neso Academy
Рет қаралды 36 М.
Maps in C++ (std::map and std::unordered_map)
30:00
The Cherno
Рет қаралды 229 М.
C++ Header Files
15:10
The Cherno
Рет қаралды 744 М.
The 'else-if' Statement in C++
11:28
Neso Academy
Рет қаралды 47 М.
POINTERS in C++
16:59
The Cherno
Рет қаралды 1 МЛН
Pointers and dynamic memory - stack vs heap
17:26
mycodeschool
Рет қаралды 1,5 МЛН
Type Conversions in C++
15:04
Neso Academy
Рет қаралды 65 М.
The 'while' Statement in C++
15:18
Neso Academy
Рет қаралды 115 М.
БАБУШКА ШАРИТ #shorts
0:16
Паша Осадчий
Рет қаралды 4,1 МЛН