Тёмный

C++ FOR BEGINNERS (2020) - What is while loop, How to count digits of a number PROGRAMMING TUTORIAL 

CodeBeauty
Подписаться 288 тыс.
Просмотров 33 тыс.
50% 1

Опубликовано:

 

25 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 91   
@CodeBeauty
@CodeBeauty 4 года назад
📚 Learn how to solve problems and build projects with these Free E-Books ⬇️ C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook 🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/ Experience the power of practical learning, gain career-ready skills, and start building real applications! This is a step-by-step course designed to take you from beginner to expert in no time! 💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10). Use it quickly, because it will be available for a limited time. #include using namespace std; void main() { //Count digits of a number int number; cout > number; if (number == 0) cout 0)//0 { //number = number / 10; number /= 10; counter++;//3 } cout
@michellesanctuary9089
@michellesanctuary9089 3 года назад
we love your programming guide channel a lot 🍷🍹
@austinjohnathan4073
@austinjohnathan4073 4 года назад
I appreciate you making all of these. I've been learning C# for the last 6 or so months but recently discovered all of my comp sci classes will be using C++ exclusively. You making these videos will have a huge impact on getting up and running for my classes. As I said before, I really appreciate it. Please keep pumping these out!
@CodeBeauty
@CodeBeauty 4 года назад
Thanks Austin, I will! :D If you have any friends that could benefit from these videos, please share them, It really means the world to me and it helps me a lot to grow my channel!
@highboyy1346
@highboyy1346 Год назад
hows college going now!
@maysonsplay3972
@maysonsplay3972 3 года назад
I wrote in order to include minus numbers too like that: while (number > 0 || number < 0) :) It works:) Thank you for the lessons :) It helps me a lot :) I am still learning:) And I like your videos so much :D
@freshPrince0
@freshPrince0 2 года назад
what about while(number != 0) ?
@EmilianoGalati
@EmilianoGalati Год назад
@@freshPrince0 very clean and elegant! 👍
@jasonalba4004
@jasonalba4004 Год назад
I did the same thing
@bubblesbaby37
@bubblesbaby37 4 года назад
C++ also has abs() which will return the absolute value of a number. You can do number = abs(number) and get the same result.
@saudalkhazriji4898
@saudalkhazriji4898 3 года назад
Before i even start watching the video i give you a like cause i know the video is going to be amazing👏
@Lafsha
@Lafsha 3 года назад
i have exam soon, i am using your tutorials thanks for your videos this is so helpfull for me , Good luck
@virx7944
@virx7944 3 года назад
For those that want to have greater than 10 Digits, change your data type from int number to long long number. I was able to get 19 digits from this data type.
@subratadas9772
@subratadas9772 2 года назад
your explanation made understanding easy ,thanks.
@hajarelsayed20
@hajarelsayed20 3 года назад
THANK YOU SO MUCH I NEEDED THIS SO BADLY
@IAmIshanSaxena
@IAmIshanSaxena 4 года назад
Yeah we need a video on debugging... and breakpoints
@dandon.3667
@dandon.3667 Год назад
Thank you so much , you help me a lot .💙💙💙
@CodeBeauty
@CodeBeauty Год назад
I'm happy to hear that ❤️
@benjaminavdic5631
@benjaminavdic5631 4 года назад
Pozdrav, obzirom da nisam bas za C++ svejedno se da nauciti a ucim vec druge programske jezike pa cu dati sansu da iskusam ovaj kanal. Dobila si novi sub
@rianvankessel3137
@rianvankessel3137 3 года назад
Yes make a video on debugging... and breakpoints, you're doing well.
@stefanskoric8046
@stefanskoric8046 4 года назад
Sorry i have a question. What if there is a situation where user enters decimal number? I fried my brain trying to make some kind of a solution but nothing crosses my mind from the stuff we covered until this video. Is solution beyond this level of knowledge? Everything else in this video is very much clear. Thanks.
@CodeBeauty
@CodeBeauty 4 года назад
The question that you're asking is a pretty complex one, and if you really are a beginner, then you probably will fry your brain trying to understand, so I'll try to explain as simple as I can. There is one fundamental problem with this question, and that is how will you know when you should stop counting?! In order to understand what I'm talking about, please try to execute this program #include #include using namespace std; void main() { float number = 123.1; number /= 10; std::cout
@findikbabi
@findikbabi 4 года назад
Yes, I would love to see a video about debugging. But I do feel like the code we wrote at 14:35 was unnecessary and made the code longer, so I just did this while(number>0 || number
@CodeBeauty
@CodeBeauty 4 года назад
👍Added debugging video to ma TODO list. You proposed a very interesting solution, and it is correct. The code below is going to work for counting digits of both positive and negative numbers! Well done! Excellent! int counter = 0; while (number!=0) { number /= 10; counter++; } Notice that I just converted your (number>0 || number
@Andy4Tune
@Andy4Tune 3 года назад
So, what happens when user types in 25 or more digit number, what is the solution?
@KanekiKen-gl8qo
@KanekiKen-gl8qo Год назад
I really just changed While(number>0) To While(number!=0) And worked properly
@CodeBeauty
@CodeBeauty Год назад
That's it
@elsafernandatorresferia886
@elsafernandatorresferia886 3 года назад
Isn't it better to declare counter at the beginning and initialize it at the while loop? Is it the same thing?
@mehranadimi9470
@mehranadimi9470 2 года назад
Thank you very much.
@joe_joe_j035
@joe_joe_j035 3 года назад
How or could I use this same counter with a randomly generated number up to lets say 10 to tune it into a simple guessing game?
@noperson-y6s
@noperson-y6s Месяц назад
A little different variation int num; int digit = 1; cout > num; if(num < 0) { num = pow(num, 2); num = sqrt(num); } while(num / 10 >= 1){ num/=10; digit++; } cout
@benyaminshirani5824
@benyaminshirani5824 3 года назад
I was just wondering if You're actually a computer scientist or a model ;)
@shamsyumar1194
@shamsyumar1194 Год назад
Hey I find your programming vedios the most easiest ones, thanks and I really need a mentor like you please be my guardian. I what to learn C++ programming lang.
@tauchainagoras6044
@tauchainagoras6044 3 года назад
Hi, why do you use system ("pause>0"); instead of return=0; ? Thanks!
@xylianasky3652
@xylianasky3652 Год назад
same question I wanna know
@branriv8417
@branriv8417 3 года назад
So how we can count more than 10 digits if that is all and int can hold? Unsigned int? Also since a negative number can be divided by 10 couldn’t we simply change the while loop to execute as long as the number is != to 0 as opposed to > 1 instead of taking the absolute value?
@Lafsha
@Lafsha 3 года назад
16:27 you should write long long instead of int variable
@kidzaki7201
@kidzaki7201 2 года назад
Thank you! Finally someone filled the "plot hole"
@sunflower9498
@sunflower9498 3 года назад
What happens in the even that the user enters a number with a zero in it? for example number 1024?
@AlvinKazaz
@AlvinKazaz Год назад
Dear Saldina, there is also another way to count digits beside 0 -> while(number !=0) { number /=10; counter++; }
@thomaspfaff1074
@thomaspfaff1074 3 года назад
a other way of solution is: int number=0; cout > number; std::string s = std::to_string(number); cout
@fisherofmen489
@fisherofmen489 3 года назад
Woudnt it be more correct to state that the counter is really counting how many times the function can perform the operation(the act of dividing by 10), rather than saying that it's grabbing the last digit because it seems like that's what the modulo operation would do
@CodeBeauty
@CodeBeauty 3 года назад
Yep, correct ☺️☺️🤗
@abdullahishehu7706
@abdullahishehu7706 2 года назад
please i did not understand from where did you get that value of 10
@40wattstudio41
@40wattstudio41 Год назад
Solved the > 10 number length problem by using type long long.
@CodeBeauty
@CodeBeauty Год назад
Yess 😃
@ivorperic297
@ivorperic297 3 года назад
Pozdrav, Zašto uopšte pišete dio u else{o množenju negativnog broja s -1} Je li se mogao while(number0) napisati ? Probao sam i meni lično radi pa ako možete molim Vas objasnite zašto taj korak sa else? Hvala :)
@MegaWeixin
@MegaWeixin Год назад
Counter variable and while loop are automatically related?
@adamheath8551
@adamheath8551 4 года назад
I think I found an alternative way to use negative numbers without the excess code or logic loops, what I did was for the while loop I put while(number != 0) and then the code, and that seems to work well, but perhaps doesn't work well elsewhere?\
@bubblesbaby37
@bubblesbaby37 4 года назад
did your solution include the negative sign in the digits count?
@manoharsagunthalla9215
@manoharsagunthalla9215 3 года назад
Dear Saldana zero too have value is’t? When entering 0 it should show you it contains one digit is in it? Suppose the user enters other than digit will it convert and tell the digits?
@newprogramer7463
@newprogramer7463 2 года назад
I can do like that: while (number0) :) Thanks Saldina
@mhdjaseem3195
@mhdjaseem3195 3 года назад
thanks, mam💕💖
@kunalbatra4166
@kunalbatra4166 4 года назад
it can also be found using logarithms: floor(log10(number)) +1 except 0 obviously 😜
@CodeBeauty
@CodeBeauty 4 года назад
I haven't seen that solution before, but you definitely can come up with different ways to solve the same programming problem. I'm glad to see different ideas and approaches in the comments! 🤓
@creativescience1533
@creativescience1533 3 года назад
Help me one project Coil winding turn counting program Aurdiono based
@rameenbabar3155
@rameenbabar3155 2 месяца назад
i want to clear something that when i'm intentionally trying to overflow my code i am not getting 10 digits instead my code says contains 9 digits #include using namespace std; int main() { int number; cout > number; if (number == 0) cout
@maulanaajiw6184
@maulanaajiw6184 2 года назад
17:00 because you input 28 digit number, which is greater than integer maximum value
@traianbadea7389
@traianbadea7389 4 года назад
Hi I want to ask if is an app C++for iPhone
@CodeBeauty
@CodeBeauty 4 года назад
You can write most of the IoS app in C++, but if you don't already have a lot of code that you just want to reuse and you are doing it from scratch, I'd say a better choice would be Swift or Objective C.
@tumusiimebrian3745
@tumusiimebrian3745 4 года назад
Break points please 🙏🙏
@zladsmusic8953
@zladsmusic8953 3 года назад
Idk why but your voice is so therapeutic XD Thanks for teaching this, keep up the videos!!
@CodeBeauty
@CodeBeauty 3 года назад
I'm happy to hear that, thanks! 🥰🤗
@tirushsanju2917
@tirushsanju2917 3 года назад
How we can enter more than 10digit number ??🤔
@MetaVaria
@MetaVaria 2 месяца назад
I didn't need to turn my negative number into a positive one to work. I did this: while (number > 0 || number < 0)
@clarrisac750
@clarrisac750 4 года назад
Thanks CodeBeauty🤩 Even as a slow learner,I am able to catch up with ur videos. Hope you can include exercises to try at the end of video, just a suggestion from me hehe.
@CodeBeauty
@CodeBeauty 4 года назад
That is a good suggestion. Sometimes throughout the videos I give you tips on how you can improve and upgrade programs that we build, but I'm also going to try and include exercises at the end whenever possible. :D
@husseinmahmoud7216
@husseinmahmoud7216 3 года назад
For the last situation you did not say what the solution was ?
@IrisFlorentinaA
@IrisFlorentinaA 3 года назад
i did exactly as you showed but my program wont compile. i enter nr 12 ,and it takes a LOT of time to get the result ...it "eats" a lot of memory and my laptop fan makes a lot of noise EDIT :: MY MISTAKE :))) i wrote while (nr > 0) { nr == nr / 10; OMGGGGGGGG
@yummy9554
@yummy9554 Год назад
#include using namespace std; int main() { int num; int counter = 0; cin >> num; while (num != 0) { num = num / 10; counter++; } cout
@eonisplaying
@eonisplaying 3 года назад
Just put the condition while (number!=0) Thanks.
@MirkoBjelica
@MirkoBjelica 3 года назад
Notice how she wasn't sure if -335 will work after adding abs part of the code and she switched to -236. Foxy Lady! :)
@thedeagle1007
@thedeagle1007 4 года назад
At 14:11 your solution to the negative number problem was inefficient in my opinion. I used an or logic gate in my while loop. Here's my code for the whole process here. *note I used n for number and c for counter. line 1 #include line 2 using namespace std; line 3 int main() line 4 { line 5 int n; line 6 int c = 0; line 7 cout > n; line 9 if (n == 0) line 10 { line 11 cout 0 || n < 0) line 16 { line 17 n /= 10; line 18 c++; line 19 } line 20 } line 21 cout
@vk2ig
@vk2ig 3 года назад
This statement cout
@thedeagle1007
@thedeagle1007 3 года назад
@@vk2ig thanks for the help!!
@subratadas9772
@subratadas9772 2 года назад
that line 15 is the acceptable as well
@subratadas9772
@subratadas9772 2 года назад
and thanks
@cuol5675
@cuol5675 3 года назад
omg the headlice trying to understand the code 😵🤯
@cuol5675
@cuol5675 3 года назад
haha after your expiation i got super relived omg it was so confusing trying to understand it by yourself...
@everydaymachi1047
@everydaymachi1047 3 года назад
it seems like people lack motivation because as the course goes on the number of views are deceasing hugely .
@arioirandoost5265
@arioirandoost5265 2 года назад
10
@ВилианПопов
@ВилианПопов 3 года назад
int number; cout > number; if (number == 0) { cout
@imnot9923
@imnot9923 2 года назад
Comment for Algor
@Roman-L
@Roman-L 4 года назад
Who else noticed that Windows taskbar is at the same level as her desk :D sooo satisfying :DDDD
@apnagaon3334
@apnagaon3334 2 года назад
Ma'am, can U please provide me a valid questions related to the C++ And I've send U a connection on LinkedIn...... If You have a.... Then plz send me a question
Далее
Why You Shouldn't Nest Your Code
8:30
Просмотров 2,8 млн
Гаджет из даркнета 📦
00:45
Просмотров 158 тыс.
Бокс - Финты Дмитрия Бивола
00:31
Master Pointers in C:  10X Your C Coding!
14:12
Просмотров 318 тыс.
Functional programming - A general introduction
11:47
Просмотров 108 тыс.
Гаджет из даркнета 📦
00:45
Просмотров 158 тыс.