C++ Program to find the Factorial of a Number using For Loop

  Рет қаралды 113,305

Example Program

Example Program

Күн бұрын

In this video you will learn to write a C++ Program to find the factorial of a number using For Loop ( Iterative Method ).
The factorial of a positive integer n, which is denoted as n!, is the product of all positive integers less than or equal to n.
That is n! = n * (n-1)*(n-2)*....*3*2*1
So 4! = 4 * 3 * 2 * 1 which is equal to 24.
Factorial for the numbers 0 and 1 is 1. That is 0! = 1 and 1! = 1. For negative numbers factorial value doesn't exists.
C++ Program to Find the Factorial of a number using Recursion ( Recursive Method )
• C++ Program to find th...
Get the Source Code of this tutorial at
www.ExamplePro...
our Social Media Pages
/ exampleprogram
/ exampleprogram
/ example_program
#CppProgramming #ExampleProgram

Пікірлер: 57
@pichonPoP
@pichonPoP Жыл бұрын
This platform shows me this video today, and last week I was struggling to do this. Finally, could do, but I'm glad to see another solution tiny different from mine.
@ExampleProgram
@ExampleProgram Жыл бұрын
glad my video helped you :)
@markdiaz4129
@markdiaz4129 4 жыл бұрын
Awesome tutorial. This was one of the problems my professor asked and you explained it perfectly. Thanks a lot
@ExampleProgram
@ExampleProgram 4 жыл бұрын
You are welcome!
@solidsnack9950
@solidsnack9950 2 жыл бұрын
Thanks for improving my problem.
@ilhan537
@ilhan537 Жыл бұрын
Thanks You have explained Correctly.
@ExampleProgram
@ExampleProgram Жыл бұрын
You are welcome
@anamggss
@anamggss Жыл бұрын
Great tutorial, I'm confused about one thing though. In all of the examples I've seen including yours the initial value of (counter = number). And it always ends up being the correct answer. However when I try this, it will instead give the result of the factorial * the original number, so I have to put (counter = number -1) to get the correct answer. Which makes sense since without the -1 it would essentially be multiplying num with itself first. Which is why it's so confusing on how this is working on your and other people's ends
@sukhandeepkaur4552
@sukhandeepkaur4552 Жыл бұрын
Amazing video ever 🎉 first time I watch your video sir it’s amazing
@ExampleProgram
@ExampleProgram Жыл бұрын
Thank you :)
@angelhabiby8894
@angelhabiby8894 5 ай бұрын
more perfect an easier than the rest of the tutorials
@ExampleProgram
@ExampleProgram 5 ай бұрын
Thank you
@solidsnack9950
@solidsnack9950 2 жыл бұрын
What can I do for larger numbers? I used long long but it didn't work.
@khilesh1815
@khilesh1815 2 жыл бұрын
Thanks bro your video really helped me to make my first factorial program
@ExampleProgram
@ExampleProgram 2 жыл бұрын
Glad I could help
@aueputin1385
@aueputin1385 Жыл бұрын
incredible explanation
@ExampleProgram
@ExampleProgram Жыл бұрын
Glad you think so!
@Shalini45006
@Shalini45006 29 күн бұрын
What input should I use for zero?
@yentarachangethelife3897
@yentarachangethelife3897 3 жыл бұрын
My dear Learning Lad❤❤❤
@niveshgaming2528
@niveshgaming2528 9 ай бұрын
which app do you use to run the code
@ExampleProgram
@ExampleProgram 9 ай бұрын
Vs code
@soumyasingh6142
@soumyasingh6142 2 жыл бұрын
Thank you sir, it helped!
@ExampleProgram
@ExampleProgram 2 жыл бұрын
You're welcome!
@Ld06
@Ld06 2 жыл бұрын
Thank you 💞💞
@ExampleProgram
@ExampleProgram 2 жыл бұрын
Most welcome
@RayyanKhan-nv5il
@RayyanKhan-nv5il 3 ай бұрын
Superb
@ExampleProgram
@ExampleProgram 3 ай бұрын
Thanks 🤗
@Oki.hou0929
@Oki.hou0929 Жыл бұрын
What about factorials in permutations?
@craftsworld3237
@craftsworld3237 2 жыл бұрын
Where do you get this vs code theme?
@ExampleProgram
@ExampleProgram 2 жыл бұрын
available by default
@amritprajapat4612
@amritprajapat4612 2 жыл бұрын
Vs code
@thecriminals6949
@thecriminals6949 Жыл бұрын
thanks sir
@ExampleProgram
@ExampleProgram Жыл бұрын
most welcome :)
@eriksaucedo4382
@eriksaucedo4382 3 жыл бұрын
i cant get it to work with large numbers like 20 how do i do that please help
@waridkhan971
@waridkhan971 3 жыл бұрын
hi sir. plz make video on program description with shamil's memory table.
@vaibhavpratap1041
@vaibhavpratap1041 3 жыл бұрын
Where are you from?
@ExampleProgram
@ExampleProgram 3 жыл бұрын
Karnataka
@M_Hamxa
@M_Hamxa 6 ай бұрын
what his compiler name ??
@ExampleProgram
@ExampleProgram 6 ай бұрын
gcc
@dawitejigu
@dawitejigu 3 жыл бұрын
why factorial = 1 in declaraton please
@ExampleProgram
@ExampleProgram 3 жыл бұрын
Sorry for late reply. For numbers 0 and 1 the factorial value is 1 Initialising factorial with 1 will work nicely with the logic used in this program.
@dukeofmilan2814
@dukeofmilan2814 3 жыл бұрын
Where is output???
@callme_SRK
@callme_SRK 2 жыл бұрын
Why fact=1 what if we give 2 3 etc...
@rollno14abhisheksharma52
@rollno14abhisheksharma52 2 жыл бұрын
But it find fac of 45 how it will display
@enesytm8867
@enesytm8867 4 жыл бұрын
bruh it ain't work
@hypermeero4782
@hypermeero4782 4 жыл бұрын
for(int counter = number ; counter > 0 ; --counter) his for loop was wrong
@ПользовательБезфамилии-к5ю
@ПользовательБезфамилии-к5ю 3 жыл бұрын
I like his accent
@Zomatsu143
@Zomatsu143 10 ай бұрын
This isn't a while loop thou
@kingteshome5034
@kingteshome5034 3 жыл бұрын
What is the name of the software or apk
@amritprajapat4612
@amritprajapat4612 2 жыл бұрын
Vs code
@salarramejo-tg3hl
@salarramejo-tg3hl Жыл бұрын
Hello sir
@ExampleProgram
@ExampleProgram Жыл бұрын
Hello
@gulbadanofficial3135
@gulbadanofficial3135 3 жыл бұрын
I got nothing
@ExampleProgram
@ExampleProgram 3 жыл бұрын
Check your code
@MillieLilth
@MillieLilth 4 жыл бұрын
I cant see nothing
@AstralLaVista
@AstralLaVista 7 күн бұрын
I am sick of people using imaginary numbers in these examples, im a noob use actual number not m
@blabruh9059
@blabruh9059 2 жыл бұрын
bruh it isn't working. lol
C++ Program to Find the Sum of All Digits of a Number
9:23
Example Program
Рет қаралды 65 М.
إخفاء الطعام سرًا تحت الطاولة للتناول لاحقًا 😏🍽️
00:28
حرف إبداعية للمنزل في 5 دقائق
Рет қаралды 69 МЛН
啊?就这么水灵灵的穿上了?
00:18
一航1
Рет қаралды 37 МЛН
C++ Program to find the Factorial of a Number using Recursion
9:03
Example Program
Рет қаралды 24 М.
you will never ask about pointers again after watching this video
8:03
Winning Google Kickstart Round A 2020 + Facecam
17:10
William Lin (tmwilliamlin168)
Рет қаралды 9 МЛН
C++ vs Rust: which is faster?
21:15
fasterthanlime
Рет қаралды 398 М.
Python Programs - Factorial Program Using for loop
10:30
Amulya's Academy
Рет қаралды 143 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 818 М.
Check If A Number Is Prime | C++ Example
8:29
Portfolio Courses
Рет қаралды 21 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН