C++ FOR BEGINNERS (2025) What is while loop, How to reverse digits of a number PROGRAMMING TUTORIAL

  Рет қаралды 23,600

CodeBeauty

CodeBeauty

Күн бұрын

Пікірлер: 61
@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() { //Reversing number int number, reversedNumber = 0;//321 cout > number; while (number!=0){ reversedNumber *= 10; //int lastDigit = number % 10; reversedNumber += number % 10; number /= 10; } cout
@PhantomByteAero
@PhantomByteAero Жыл бұрын
your code is wrong. "void main()" my app can not run it as that. How can I fix this?
@wiazowski1
@wiazowski1 4 жыл бұрын
Love the content and the way you are teaching. Don't stop. You are doing great. Simple and easy
@anotherryderinthestorm9568
@anotherryderinthestorm9568 4 жыл бұрын
Please keep the tutorials coming. I'll be keeping an eye out for something on arrays. Your explanations are very helpful for a new student like me. Very much appreciated! you should post a crypto address so you can more easily be compensated for your efforts. I'm glad you liked the pineapple juice suggestion.
@CodeBeauty
@CodeBeauty 4 жыл бұрын
Pineapple juice is the bomb! I'll definitely put more videos. It's just that I've been sick in the past 10 days, and I couldn't really speak for longer than 15-20 seconds without coughing, so filming tutorials was impossible. A new video will be up today around 6 PM UTC time. :) I'll cover arrays as well in the future! Edit: Video will be published tomorrow because I'm having problems with upload! 😕
@tan777IT
@tan777IT 5 ай бұрын
Thank you for thoroughly explaining everything step by step towards the end of the video.
@shivam_dxrk
@shivam_dxrk 4 жыл бұрын
I didnt see the video just tried to solve the problem and came up with this, works fine upon execution #include using namespace std; int main() { int n; cout > n; while (n > 0) { int counter, f; f = n; n = n/10; counter = f - n*10; cout
@kelvinwilliams2908
@kelvinwilliams2908 4 жыл бұрын
I see the difference now. In both cases you want to remove the last digit but in one case (Tut12) you want to lose the digit and in the other case(Tut 13), you want to keep it. Very clever!
@actor19927
@actor19927 4 жыл бұрын
Drago mi te vidjeti Saldina nakon dugo godina, sretno s radom 😊
@CodeBeauty
@CodeBeauty 4 жыл бұрын
Ne znam ko je, ali hvala ti puno! :D
@wasimkhan-th1it
@wasimkhan-th1it 4 жыл бұрын
I m student of bscs.your video really helps me. Thank you
@CodeBeauty
@CodeBeauty 4 жыл бұрын
That is awesome! Happy to help 🤗
@soldiers4christ495
@soldiers4christ495 Жыл бұрын
Your videos are really helpful i'm only in eighth grade and i am understanding the concepts that even the bigger grades don't understand. Keep doing what your doing.
@soldiers4christ495
@soldiers4christ495 Жыл бұрын
LIKE AND SUB EVERY ONE!!!!!!!!!!!!!!!!!!!!!!!!!
@yashjadhav6838
@yashjadhav6838 3 жыл бұрын
thank u so much now ik how to find last digit using number % 10 and remove last digit by using number / 10 this methods will come handy in future
@yashsonawane905
@yashsonawane905 3 жыл бұрын
Best use of / and % operator. Hats off :)
@CodeBeauty
@CodeBeauty 3 жыл бұрын
🙏💙
@omaristaitia5628
@omaristaitia5628 3 жыл бұрын
you are the best Saldina , very nice
@sasajuricevic1330
@sasajuricevic1330 4 жыл бұрын
Hello CodeBeauty, this is very helpfull video for understanding modulo and while loop....Will be also interesting to se how to manipulate char or double type of variables on this example. Will be very helpfull to everybody to understand that for diferent type of var there must be also different aproach :)... BTW You are great !!! idemo dalje :)
@yummy9554
@yummy9554 2 жыл бұрын
This harder than previous lesson, am think that because I lack understanding it feel more like about know the formula and am bad at math so I did not think of way to comeup with how to do it myself, am just sharing but this lesson is very good it is clear and am able understand how it happen just that am think that I won't comeup with a way to reverse engineer it if am asked to do without knowing formula because am bad at math 😆 int num; int counter = 0; cin >> num; while (num != 0) { counter = counter * 10; counter = counter + num % 10; num = num / 10; } cout
@jerseychou4323
@jerseychou4323 Жыл бұрын
Thank you CodeBeauty!
@patrickmafabi5832
@patrickmafabi5832 3 жыл бұрын
Hi Saldina! thank you for your great work. i would like to know what the void means please
@aquibkaneki571
@aquibkaneki571 4 жыл бұрын
please explain difference about int(main) and void(main)
@IrisFlorentinaA
@IrisFlorentinaA 3 жыл бұрын
she explained in the first or the second video of this C++ for beginners playlist, check there IN THE COMMENT SECTION
@cuol5675
@cuol5675 3 жыл бұрын
finally my calculation program came in handy now, lol
@acridpie4492
@acridpie4492 Жыл бұрын
If one is unable to solve problems in a snap, do you think that person can ever be a good programmer or lets say a somewhat programmer?
@CodeBeauty
@CodeBeauty Жыл бұрын
Of course, it will take you a few years of practice to feel confident in your knowledge and even most experienced developers make mistakes and don't solve new problems in a snap 😃
@MarceloMoraes
@MarceloMoraes Жыл бұрын
A great video. If the last digit of a number is 0 (like 1230) it shows also 321 (it make sense , but...) how to show all digits including the last 0 like 0321 ???
@lolll7505
@lolll7505 8 ай бұрын
int main() { bool firstDigitZero = {}; int number = {}, reversedNumber = 0; cout > number; while (number != 0) { reversedNumber *= 10; reversedNumber += number % 10; number /= 10; if (reversedNumber == 0) firstDigitZero = true; } (firstDigitZero) ? cout
@lolll7505
@lolll7505 8 ай бұрын
For multiple 0 -> int main() { short firstDigitZeroCounter = {}; int number = {}, reversedNumber = {}; cout > number; while (number != 0) { reversedNumber *= 10; reversedNumber += number % 10; number /= 10; if (reversedNumber == 0) firstDigitZeroCounter++; } cout
@mhdjaseem3195
@mhdjaseem3195 3 жыл бұрын
thanks, mam💕💖
@CodeBeauty
@CodeBeauty 3 жыл бұрын
😘😘
@ayeshaamjad2513
@ayeshaamjad2513 4 жыл бұрын
best explained.
@CodeBeauty
@CodeBeauty 4 жыл бұрын
😊🤗
@branriv8417
@branriv8417 3 жыл бұрын
If I’m not mistaken when going through the final iteration we are assigning 1/10 to number and (1/10)%10 to reversedNumber so the program must know to round (1/10)%10 up to 1? Is it safe to assume that in C++ any number > 0 but < 1 % 10 will be rounded up to 1?
@perezgalvanalexiaberenice3194
@perezgalvanalexiaberenice3194 4 жыл бұрын
Great videos with very good explanations! I´m starting to learn to code and it has been very helpful but I have a doubt with the difference between int main ( ) and void main ( ), how does each main ( ) affect the code?
@IrisFlorentinaA
@IrisFlorentinaA 3 жыл бұрын
she explained in the first or the second video of this C++ for beginners playlist, check there IN THE COMMENT SECTION
@perezgalvanalexiaberenice3194
@perezgalvanalexiaberenice3194 3 жыл бұрын
@@IrisFlorentinaA Thanks!
@mpteevee
@mpteevee 2 жыл бұрын
how would u reverse 10 digits? ( user inputs 10 numbers and it outputs those reversed )
@memesgrenade7915
@memesgrenade7915 3 жыл бұрын
actually i didn't understanded what does this (%) mean can you please explain with a reply?
@branriv8417
@branriv8417 3 жыл бұрын
You have to watch her previous videos but % (modulo) operator returns the remainder of two operands. For example 5%2 would be 1 because if you take 5/2 there would be a remainder of 1. % only works with integers (not with decimal or floating point numbers)
@kelvinwilliams2908
@kelvinwilliams2908 4 жыл бұрын
In the Tutorial 13 algorithm, the third step was to take the last digit from the entered number and to do this you used the Modulo operation.However, in Tutorial 12 there was a similar algorithm and again we had to remove the last digit of a number. In this case you divided the number by 10 and lost the decimal place. My understanding of the Modulus operation (from Tutorial 6 on Operators) was that it gives the remainder of a division so that 5%2 = 1. So why in Tutorial 13 did you use the Modulo operation rather than dividing by 10 as in Tutorial 12?
@CodeBeauty
@CodeBeauty 4 жыл бұрын
As you said yourself, % operator gives you the remainder after you divide two whole numbers. One very convenient thing is that each time that you modulate your int number by 10, you are going to get the last digit of that number. For example: 123/10=12 (that 3 is just thrown away) 123%10=3 (with % operator, we get that 3 remainder) In the Tutorial 12, we are just counting digits of a number, which means that for each digit in our number we just need to increase the counter of digits, and then we can throw that digit away. That is why in Tutorial 12, I just do: number/=10; (throw one digit away) counter++;( increase the counter of digits) In Tutorial 13, we are reversing the number. That means that we have to: lastDigit=number%10; (take the last digit of users number, and store it somewhere, not just throw it away) reversedNumber+=lastDigit; (add that digit to our reversed number) number/=10; (throw one digit away for users number, so that in the next iteration we don't get the same number that we had in the previous iteration, but a number that has one digit less) So the key difference is that, when you use / operator in an expression like number=number/10, you are going to remove one digit from your number and store the result back in your number variable . But when you use % operator in an expression like lastDigit=number%10, you are just going to get the last digit of your number and store it in the lastDigit variable . And depending on whether you need to take the last digit of the number and do something with it, or you just need to get rid of it, you're going to use one or the other. Understood? 😊
@traianbadea7389
@traianbadea7389 4 жыл бұрын
@@CodeBeauty It is very important that you explained here. I had the same problem's understanding like Kelvin, but here you explain very well the difference between these. Thank you All the best
@puneetjadaun4943
@puneetjadaun4943 3 жыл бұрын
I tried to run the program but I am getting an error saying Time Limit Exceeded. What to do ???
@harshalshelekar6010
@harshalshelekar6010 3 жыл бұрын
and what we gonna do about '0' .... it doesn't show .... and also i got this error i am beginner so will you explain me ReverseNumber.cpp:4:1: error: '::main' must return 'int' 4 | void main()
@JarekAtWork
@JarekAtWork Жыл бұрын
One variable: int main() { cout number; if (number < 0) { number *= -1; cout 0) { cout
@rokomedancic349
@rokomedancic349 Жыл бұрын
Sta se desava ako deklariramo varijablu unutar petlje? Varijabla se svaki put deklarira? Sta ne trosi to svaki put drugu lokaciju u memoriji? Sta nije bolje da se jedanput deklarira van petlje, pa da se unutar petlje mjenja samo vrijednost? Taj nacin na koji si ti napravila sam vidio vise puta, ali ga ne razumjem. Inace odlican algoritam i odlican primjer! :)
@stevend1394
@stevend1394 4 жыл бұрын
This maam is cute, so I'll subscribe it haha
@sarazamani2793
@sarazamani2793 9 ай бұрын
Love it
@robertkalny4152
@robertkalny4152 3 жыл бұрын
May be another solution how we can get last digit of number. Is there something wrong from point of programators view? while (number != 0) { reversedNumber *= 10; reversedNumber = reversedNumber + (number - (number / 10 * 10)); number = number / 10; } by the way, your tutorials are amazing, I program for a long time as a self-taught person but I miss these basics. Beautifully understandable
@sarazamani2793
@sarazamani2793 9 ай бұрын
Awesome
@sanadshafie1484
@sanadshafie1484 3 жыл бұрын
OR while (number!=0) { cout
@ahmadosama2652
@ahmadosama2652 2 жыл бұрын
Also we can do it like this rev = rev * 10 + n%10;
@Павелик-з4е
@Павелик-з4е 4 жыл бұрын
My girl.
@teekay4282
@teekay4282 Жыл бұрын
For beginners and I’m seeing void main and system pause🙄
@ROYALNIL_SITE
@ROYALNIL_SITE Жыл бұрын
VERY THANKS SALDINA ! #ROYALNIL
@imnot9923
@imnot9923 2 жыл бұрын
Comment for Algor
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН