📚 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
@michellesanctuary90893 жыл бұрын
we love your programming guide channel a lot 🍷🍹
@austinjohnathan40734 жыл бұрын
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!
@CodeBeauty4 жыл бұрын
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!
@highboyy13462 жыл бұрын
hows college going now!
@bubblesbaby374 жыл бұрын
C++ also has abs() which will return the absolute value of a number. You can do number = abs(number) and get the same result.
@virx79443 жыл бұрын
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.
@maysonsplay39724 жыл бұрын
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
@freshPrince02 жыл бұрын
what about while(number != 0) ?
@EmilianoGalati2 жыл бұрын
@@freshPrince0 very clean and elegant! 👍
@jasonalba4004 Жыл бұрын
I did the same thing
@saudalkhazriji48984 жыл бұрын
Before i even start watching the video i give you a like cause i know the video is going to be amazing👏
@IAmIshanSaxena4 жыл бұрын
Yeah we need a video on debugging... and breakpoints
@Lafsha3 жыл бұрын
16:27 you should write long long instead of int variable
@kidzaki72013 жыл бұрын
Thank you! Finally someone filled the "plot hole"
@Lafsha3 жыл бұрын
i have exam soon, i am using your tutorials thanks for your videos this is so helpfull for me , Good luck
@noperson-y6s3 ай бұрын
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
@findikbabi4 жыл бұрын
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
@CodeBeauty4 жыл бұрын
👍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
@subratadas97723 жыл бұрын
your explanation made understanding easy ,thanks.
@hajarelsayed203 жыл бұрын
THANK YOU SO MUCH I NEEDED THIS SO BADLY
@KanekiKen-gl8qo Жыл бұрын
I really just changed While(number>0) To While(number!=0) And worked properly
@CodeBeauty Жыл бұрын
That's it
@maulanaajiw61842 жыл бұрын
17:00 because you input 28 digit number, which is greater than integer maximum value
@thomaspfaff10743 жыл бұрын
a other way of solution is: int number=0; cout > number; std::string s = std::to_string(number); cout
@tauchainagoras60443 жыл бұрын
Hi, why do you use system ("pause>0"); instead of return=0; ? Thanks!
@xylianasky3652 Жыл бұрын
same question I wanna know
@shamsyumar11942 жыл бұрын
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.
@benjaminavdic56314 жыл бұрын
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
@rianvankessel31373 жыл бұрын
Yes make a video on debugging... and breakpoints, you're doing well.
@dandon.3667 Жыл бұрын
Thank you so much , you help me a lot .💙💙💙
@CodeBeauty Жыл бұрын
I'm happy to hear that ❤️
@elsafernandatorresferia8863 жыл бұрын
Isn't it better to declare counter at the beginning and initialize it at the while loop? Is it the same thing?
@domus_k4 жыл бұрын
Idk why but your voice is so therapeutic XD Thanks for teaching this, keep up the videos!!
@CodeBeauty4 жыл бұрын
I'm happy to hear that, thanks! 🥰🤗
@joe_joe_j0353 жыл бұрын
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?
@Andy4Tune3 жыл бұрын
So, what happens when user types in 25 or more digit number, what is the solution?
@stefanskoric80464 жыл бұрын
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.
@CodeBeauty4 жыл бұрын
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
@adamheath85514 жыл бұрын
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?\
@bubblesbaby374 жыл бұрын
did your solution include the negative sign in the digits count?
@sunflower94983 жыл бұрын
What happens in the even that the user enters a number with a zero in it? for example number 1024?
@40wattstudio41 Жыл бұрын
Solved the > 10 number length problem by using type long long.
@CodeBeauty Жыл бұрын
Yess 😃
@branriv84173 жыл бұрын
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?
@yummy95542 жыл бұрын
#include using namespace std; int main() { int num; int counter = 0; cin >> num; while (num != 0) { num = num / 10; counter++; } cout
@benyaminshirani58243 жыл бұрын
I was just wondering if You're actually a computer scientist or a model ;)
@AlvinKazaz Жыл бұрын
Dear Saldina, there is also another way to count digits beside 0 -> while(number !=0) { number /=10; counter++; }
@newprogramer74633 жыл бұрын
I can do like that: while (number0) :) Thanks Saldina
@traianbadea73894 жыл бұрын
Hi I want to ask if is an app C++for iPhone
@CodeBeauty4 жыл бұрын
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.
@manoharsagunthalla92153 жыл бұрын
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?
@creativescience15333 жыл бұрын
Help me one project Coil winding turn counting program Aurdiono based
@MegaWeixin Жыл бұрын
Counter variable and while loop are automatically related?
@abdullahishehu77062 жыл бұрын
please i did not understand from where did you get that value of 10
@mehranadimi94702 жыл бұрын
Thank you very much.
@fisherofmen4893 жыл бұрын
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
@CodeBeauty3 жыл бұрын
Yep, correct ☺️☺️🤗
@kunalbatra41664 жыл бұрын
it can also be found using logarithms: floor(log10(number)) +1 except 0 obviously 😜
@CodeBeauty4 жыл бұрын
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! 🤓
@thedeagle10074 жыл бұрын
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
@vk2ig3 жыл бұрын
This statement cout
@thedeagle10073 жыл бұрын
@@vk2ig thanks for the help!!
@subratadas97723 жыл бұрын
that line 15 is the acceptable as well
@subratadas97723 жыл бұрын
and thanks
@tumusiimebrian37454 жыл бұрын
Break points please 🙏🙏
@ivorperic2973 жыл бұрын
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 :)
@mhdjaseem31953 жыл бұрын
thanks, mam💕💖
@clarrisac7504 жыл бұрын
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.
@CodeBeauty4 жыл бұрын
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
@eonisplaying3 жыл бұрын
Just put the condition while (number!=0) Thanks.
@MetaVaria4 ай бұрын
I didn't need to turn my negative number into a positive one to work. I did this: while (number > 0 || number < 0)
@tirushsanju29173 жыл бұрын
How we can enter more than 10digit number ??🤔
@rameenbabar31554 ай бұрын
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
@husseinmahmoud72163 жыл бұрын
For the last situation you did not say what the solution was ?
@IrisFlorentinaA3 жыл бұрын
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
@MirkoBjelica4 жыл бұрын
Notice how she wasn't sure if -335 will work after adding abs part of the code and she switched to -236. Foxy Lady! :)
@everydaymachi10473 жыл бұрын
it seems like people lack motivation because as the course goes on the number of views are deceasing hugely .
@cuol56753 жыл бұрын
omg the headlice trying to understand the code 😵🤯
@cuol56753 жыл бұрын
haha after your expiation i got super relived omg it was so confusing trying to understand it by yourself...
@ВилианПопов3 жыл бұрын
int number; cout > number; if (number == 0) { cout
@Roman-L4 жыл бұрын
Who else noticed that Windows taskbar is at the same level as her desk :D sooo satisfying :DDDD
@arioirandoost52652 жыл бұрын
10
@imnot99232 жыл бұрын
Comment for Algor
@apnagaon33342 жыл бұрын
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