C++ FOR BEGINNERS (2025) - For loop, How to calculate factorial of a number PROGRAMMING TUTORIAL

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 71

  • @CodeBeauty
    @CodeBeauty  4 года назад +20

    📚 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()
    {
    //The factorial of a number
    int number;
    cout > number;
    int factorial = 1;
    //6!=1*2*3*4*5*6=720
    //for (int i = 1; i = 1; i--) {
    factorial = factorial * i;
    }
    cout

  • @angietodaro381
    @angietodaro381 4 года назад +9

    Your explanation is so detailed, its great. Thanks so much :D

  • @williamwelmans8648
    @williamwelmans8648 3 года назад +5

    You are an excellent teacher! Thank you very much!

  • @himanshugaikwad4998
    @himanshugaikwad4998 3 года назад +4

    Ur teaching is so beautiful 🤩
    Just like YOU!!!!!

    • @CodeBeauty
      @CodeBeauty  3 года назад +3

      Thank you so much! 😃

  • @venkateshnayak3454
    @venkateshnayak3454 3 года назад

    The way you are teaching is very good..Thank you very much Saldina

  • @lukachilukusha6437
    @lukachilukusha6437 3 года назад +1

    Thanks a lot, I am learning from you different way to apply logic in programming. This is really helpful and I am how see different ways to solve different problems. Thanks 👍

  • @javanehmoghavi3954
    @javanehmoghavi3954 10 месяцев назад

    excellent, your trainings are awesome

  • @iirxit
    @iirxit 3 года назад +1

    You are the best
    Can you make more examples of for loop please 🙏

  • @ЭлбекМелибаев
    @ЭлбекМелибаев 2 года назад +1

    just loved your explanation))

  • @pbadibi
    @pbadibi Год назад +1

    thank you for existing 🦋

    • @CodeBeauty
      @CodeBeauty  Год назад

      Thank you for being such a supportive and kind person 💗

  • @jwawong
    @jwawong 3 года назад +1

    Your videos are amazing! Thank you

  • @dushyantvyas3589
    @dushyantvyas3589 2 года назад +1

    Can you please make a dedicated video on 'for loop' and 'while loop' in much greater details? such as nested loops, pattern programs using loops (basic to advance level). I'm having hard time with loops especially when it comes to pattern to draw a shapes using loops. I face difficulties behind its code generation from logic.

  • @onetwo-di9cv
    @onetwo-di9cv 7 месяцев назад

    Hi there, I am glad I find your brief tutorial for factorial using this for loop method. I tried & it's amazing!! But I find that the display result start to get wrong when it comes to number 13! & above. Is there any solution for this case?

  • @Nishanth24s
    @Nishanth24s 3 года назад

    This tutorial was very much helpful, even though i dont have any Coding background and i can easily understand your explanation and get the output seamless.
    Please do make a tutorial on
    1.Counting vowels.
    2. Reverse a string.
    3.To print Fibonacci series.
    Thank you Mam.

  • @tankrides
    @tankrides Год назад

    double recursiveFactorial(int numBer) { if (numBer == 0) return numBer; return numBer + recursiveFactorial(numBer - 1); }

  • @jaren_c
    @jaren_c 2 года назад

    Excellent explanation!

  • @TheJoshuamcgowan
    @TheJoshuamcgowan 2 года назад +1

    super helpful. thx!

  • @celestiaaldreaams
    @celestiaaldreaams 3 года назад

    i did this in class today!! :)

  • @Himalayas1921
    @Himalayas1921 3 года назад

    Thankxxx alot. Explained very well# keep it up.

  • @40wattstudio41
    @40wattstudio41 Год назад

    Any examples of when you would use a factorial in a game or software?

  • @emilianoguillenmedina1066
    @emilianoguillenmedina1066 4 года назад +3

    regards from México

    • @CodeBeauty
      @CodeBeauty  4 года назад +4

      Saludos para el México y bienvenido Emiliano! 🤗
      Increasing or decreasing the counter and setting the condition is considered the best practice to end the loop.
      However, there are other ways to terminate the execution of your loop if you really need to use them.
      Among those are break and goto statements, but if you make a habit of using these in large projects, you can find yourself maintaining code that is prone to bugs, very hard to understand (spaghetti code), and difficult to trace the control flow of a program.
      Because of that, I wouldn't encourage using them.
      Each time that you find yourself resorting to one of these in order to solve a problem, you should ask yourself how could you write that code without one of those, because in most cases it can be done.
      With that being said, there is one situation where they can be useful, and that would be for jumping out of deeply-nested loops since that would be often cleaner than using a condition variable and checking it on each level.

  • @makoto7275
    @makoto7275 3 года назад +1

    Thank you so much!

  • @MrHappyChappyX
    @MrHappyChappyX 4 года назад +2

    Hey CodeBeuty, total novice here and going through your videos have made the world of code less scary! I do have one question about the for loop, in the lines:
    for (int i = 1; i

    • @robertbruce5513
      @robertbruce5513 4 года назад +1

      initialization (i=1)-->then it checks the condition(i if the condition satisfies,it executes the statement/statements between the curly braces--> then it goes to the increment/decrement part(here,i++)-->then value of i
      is updated-->checks condition...it goes on and on until the condition is not satisfied or you use break statement. :V

    • @vk2ig
      @vk2ig 3 года назад +1

      You can think of it this way if you wish - the "for" loop works just like this implementation of a "while" loop:
      int i = 1;
      while (i

  • @darius2955
    @darius2955 Год назад

    Thank you ☺️

  • @mahedirony3408
    @mahedirony3408 2 года назад

    Easy to understand
    take love

  • @TheDora422
    @TheDora422 3 года назад

    Is the 3rd part (increasing/decreasing)of the For-loop always ignored on the first run? If it would just executed the conditions in the brackets after another ,the inserted number would be always In or decreased before executing the loop

  • @clarrisac750
    @clarrisac750 4 года назад +3

    Wanna ask I noticed that the factorial for number beyond 12 is inaccurate which most probably due to max number of integer is 2^31.How can I modify my code so that it can calculate beyond 12?

    • @CodeBeauty
      @CodeBeauty  4 года назад +1

      Exactly! The number that you want to store in your int type is too big, so it cannot be stored into an int.
      I have talked about that in this video ruclips.net/video/solufpKPDwY/видео.html, so you can find more details there
      As far as I know, the long long data-type is the largest built-in integral datatype.
      So you can use unsigned long long int to store longer number and calculate the larger factorial.
      If you need an even bigger number than you'll have to use libs that are designed to work with extremely large numbers :D

    • @emilianoguillenmedina1066
      @emilianoguillenmedina1066 4 года назад

      I remeber that you can use doble instead int to doble the capacity of your variable, you can try it.

  • @jamieMcSorley-c4i
    @jamieMcSorley-c4i 4 месяца назад

    I noticed if I enter a letter or a symbol, the program immediately runs through the code asking to enter the pin, but doesn't allow a pin to be entered, then the program defaults to "Blocked". Is there a way to debug this? I was thinking of using another if statement

  • @ChrisVideosGreek
    @ChrisVideosGreek 3 года назад

    l mostly use an intializer for i when using for loops :D

  • @ChrisVideosGreek
    @ChrisVideosGreek 3 года назад

    One day, you HAVE to teach the value outside functions it's pretty good.

  • @tcrawford8430
    @tcrawford8430 4 года назад

    How can I loop the factorial to adjust to the user input number in my for loop?

  • @anthonywilson8366
    @anthonywilson8366 2 года назад

    How can I increase in increments , do you have a video on that maddam?

  • @yashjadhav6838
    @yashjadhav6838 3 года назад

    Thanks a lot

  • @HarderThanCalculus
    @HarderThanCalculus 2 года назад

    to check for negative numbers I stuck in a little if else statement: if(number

    • @day4834
      @day4834 2 года назад

      Hi, this removes the negative numbers from the equation:
      #include
      using std::cout;
      using std::cin;
      using std::endl;
      int main() {
      int number, factorial = 1;
      cout number;
      if (number >= 0) {
      if (number == 0)
      cout

  • @sayedosama4687
    @sayedosama4687 3 года назад

    god bless you ❤

  • @amaulearyan9912
    @amaulearyan9912 3 года назад

    How can i calculate 100! ? as this programme show 100! = 0 and 20! = in negative ?

  • @mhdjaseem3195
    @mhdjaseem3195 3 года назад

    thanks, mam💕💖

  • @akanguven114
    @akanguven114 Год назад

    Hello, I am entering my info but the book has not been sent to my mail.. Thanks, I am Bosnian :)

  • @trippics8465
    @trippics8465 3 года назад +1

    Pl.. make a video of find factorial no using recursion.

    • @CodeBeauty
      @CodeBeauty  3 года назад +1

      I already have that video: ruclips.net/video/MwfvXDfaZeI/видео.html
      Hope it helps!😃

    • @trippics8465
      @trippics8465 3 года назад

      @@CodeBeauty Thanks Ma'am.

    • @trippics8465
      @trippics8465 3 года назад

      @@CodeBeauty Thank You So much dear.

  • @lopez5371
    @lopez5371 2 года назад

    I want the answer to be like for example as " 3!=3*2*1=6"... how can we do this???

  • @ir4kli
    @ir4kli 3 года назад

    #include
    using namespace std;
    int main(){
    int num,factorial=1;
    cin>>num;
    while(num>0){
    factorial=factorial*num;
    num--;
    }cout

  • @jerseychou4323
    @jerseychou4323 Год назад

    tks

  • @simonasulcova8835
    @simonasulcova8835 3 года назад

    12:41 Can somebody please tell me, how did she do this? Every time I try this it comments like this: /* */. Id be happy for any advice, guys

  • @findikbabi
    @findikbabi 4 года назад +2

    I upgraded to code to include the possibilities of the user entering 0 or a negative number you can check it out and give me tips
    int number;
    cout > number;
    int factorial = 1;
    if (number == 0)
    {
    cout

    • @CodeBeauty
      @CodeBeauty  4 года назад +3

      This will work. Now, here is an idea of how you can do the same thing with less code. How about reducing your code to this:
      int number;
      cout > number;
      int factorial = 1;
      if (number < 0)
      {
      cout = 1; i--)
      {
      factorial = factorial * i;
      }
      cout

    • @findikbabi
      @findikbabi 4 года назад +2

      CodeBeauty Thank you

  • @zakariaaenajjachi2127
    @zakariaaenajjachi2127 3 года назад

    there is a more better method wich is just do factoriel = number *(number+1)/2

  • @imnot9923
    @imnot9923 2 года назад

    Comment for Algor

  • @Byynx
    @Byynx Год назад

    For the health of your eyes and overall health i strongly advise you to change the background to a dark color.

  • @omaristaitia5628
    @omaristaitia5628 3 года назад

    So nice Saldina you look like million Dollar

  • @dorianbs43
    @dorianbs43 2 года назад

    Thank you so much