Тёмный

#18 C Recursion | C Programming For Beginners 

Programiz
Подписаться 175 тыс.
Просмотров 94 тыс.
50% 1

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

 

27 окт 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 112   
@programizstudios
@programizstudios 2 года назад
🔥Finding it Damn Hard to Understand C Programming? Learn to code-the right way-with interactive lessons, quizzes & challenges. Build a strong programming base; it's IMPORTANT! Try Programiz PRO for Free: bit.ly/master-c-programming
@manishgoud2381
@manishgoud2381 Год назад
Tq so much maam for your explanation
@AbhiramDeshpande-fe1vi
@AbhiramDeshpande-fe1vi Год назад
#include int sum(int n); int main(){ int number; printf("enter a number :"); scanf("%d",&number); int result = sum(number); printf("the answer is %d ",result); return 0; } int sum (int n){ if(n>0){return n*sum(n-1);} else {return 1;} }
@mfarzan96
@mfarzan96 Год назад
@@AbhiramDeshpande-fe1vi you forgot to add math.h header file
@AbhiramDeshpande-fe1vi
@AbhiramDeshpande-fe1vi Год назад
@@mfarzan96 thanks bro
@hrkhrld
@hrkhrld 3 месяца назад
@@AbhiramDeshpande-fe1vi what if the user inputs a negative value. What will your code be?
@SoniKumari-ym4vl
@SoniKumari-ym4vl 2 года назад
Please mam upload videos fast ur teaching style is best after so many complicated videos i found yours and it the best
@c_learner_on_linux
@c_learner_on_linux Год назад
I suggest for myself the programming task before seeing the task. Ma'am, your teaching is one of the best I have ever seen so far.
@programizstudios
@programizstudios 2 года назад
Q. Which of the following statements is false? A. A function that calls itself is called recursive function B. Conditional statement prevents infinite recursive call C. Recursive Function always return some value D. None of the above
@atulanand1954
@atulanand1954 2 года назад
D is the answer
@ВахидуззаманШуво
@ВахидуззаманШуво 2 года назад
D
@sakshiruikar2796
@sakshiruikar2796 2 года назад
None of the above
@yemre401
@yemre401 2 года назад
D
@analiebenocilla3009
@analiebenocilla3009 2 года назад
D
@DannyDatsWhacc
@DannyDatsWhacc 9 дней назад
this is where Im starting to struggle. I need to revise more on this topic
@blessingmagombedze7678
@blessingmagombedze7678 4 дня назад
Us
@josephmusangu5901
@josephmusangu5901 Год назад
Been saving my life, everything seems so smooth and simple
@streamvision145
@streamvision145 5 месяцев назад
Answer is C. a Recursive function doesn't have to return value all the time. It can be used to just pass parameters.
@NGOFFICAL9
@NGOFFICAL9 2 года назад
Mam please upload videos daily in c programming language
@timetocreate62
@timetocreate62 2 года назад
#include #include int main() { // Write C code here int number,result; printf("Write a whole number:"); scanf("%d", &number); result = factoriel(number); printf("Factoriel = %d", result); return 0; } int factoriel(int n){ if (n != 0){ return n * factoriel(n-1); } else { return n+1; } }
@datuboharry6103
@datuboharry6103 Год назад
You’ll use (n != 1) here since you’re dealing with multiplication. Hence the function always returns 0
@datuboharry6103
@datuboharry6103 Год назад
If you leave it at 0, it’ll run “return 1 * (1-1)” which is 1 * 0 on the last loop. Making it return zero always
@Hut0909
@Hut0909 2 месяца назад
​@@datuboharry6103Makes sense, thank you!
@jaisonabraham7381
@jaisonabraham7381 2 года назад
Hi Padma, Your class is very good and easy to understand. All the best
@Kenara_Music
@Kenara_Music Год назад
I do not understand where the second number in the sums in the image come from. For example, in the first one where does the6 in (4 + 6 = 10) come from?
@pedrofranco7247
@pedrofranco7247 5 месяцев назад
4+3+2+1 = 10
@testingsomething5280
@testingsomething5280 4 месяца назад
@@pedrofranco7247 I get it but where did the 6 come from?
@pedrofranco7247
@pedrofranco7247 4 месяца назад
@@testingsomething5280 It comes from the iteration below: 3+3 =6, in which the second 3 comes from the other iteration: 2+1=3, and the 1 comes from yet another iteration: 1+0=1. Everything together is the same as 4+3+2+1=10
@cxuri
@cxuri Год назад
Explained perfectly
@vishalkadkal
@vishalkadkal Год назад
#include #include int main(){ int number,result; printf("Enter the positive number = "); scanf("%d",&number); result=factorial(number); printf("%d",result); return 0; } int factorial(int n){ if(n != 0){ return n* factorial (n-1); } else{ return n+1; } }
@hinfarana3083
@hinfarana3083 Год назад
Your topics are really understandable to me...plz would you like to post Dsa course ...that would be very helpful
@Selcuk._._
@Selcuk._._ 6 месяцев назад
/*Create a program that computes the factorial of a number. • Take input from user • Pass the input value to a function. • Inside the function check if the number is greater than O. • If true, return number multiplied by a recursive call to the function with parameter 1 less than number Otherwise, return 1. */ int factorial(int n) { if (n != 0) { if (n < 1) return 1; return n * factorial(n - 1); }else return 1; }
@rohankumardhariya906
@rohankumardhariya906 2 года назад
Please finish this course soon
@IfycoolAfrica
@IfycoolAfrica Год назад
programming squeeze D. None of the above
@karishmasherinjenifer8291
@karishmasherinjenifer8291 3 месяца назад
Do you mean "Programming quiz"??
@IfycoolAfrica
@IfycoolAfrica 3 месяца назад
@@karishmasherinjenifer8291 yah
@KaanUNSAL-v5y
@KaanUNSAL-v5y Год назад
Very clear. Thanks
@oluwatobilobakassim6393
@oluwatobilobakassim6393 Год назад
Thanks for the help
@Agastya007
@Agastya007 2 года назад
keep building the content!!🙂
@arantebw
@arantebw 4 месяца назад
Thank you!
@prajwal_bagewadi
@prajwal_bagewadi 2 года назад
very nice video and explaining. ❤🙏😊
@rayan_lupo3021
@rayan_lupo3021 10 месяцев назад
I've recycled the code of the previous exercise and I've changed the + on the 20th line with * #include int factorial(int n); int main() { int number,result; printf("Enter a number: "); scanf("%d", &number); result = factorial(number); printf("Factorial number = %d", result); return 0; } int factorial(int n){ if (n > 0){ return n * factorial(n-1); } else { return 1; } }
@light-warrior
@light-warrior 8 месяцев назад
Task: #include #include int mult(int n); int main() { int number, result; printf("enter a number: "); scanf("%d ", &number); result = mult(number); printf("multiplication = %d", result); return 0; } int mult(int n) { if (n > 0) { return n * mult(n-1); } else { return 1; } } Quiz: D is the correct option.
@hrkhrld
@hrkhrld 3 месяца назад
In the programming task at the end, what if the user inputs a negative value? What will be the new code to indicate that the user input is invalid?
@loveafinni
@loveafinni Год назад
Awesome!
@danieldaniekl6222
@danieldaniekl6222 29 дней назад
i just realized recursing is useful for sorting algorithms
@dblegends6260
@dblegends6260 2 года назад
Thank you mam ❣️😊
@ironmonkey1990
@ironmonkey1990 5 месяцев назад
very good!
@onomemafuru9496
@onomemafuru9496 2 года назад
How does the compiler know to convert sum(number) to sum(n) since number and n are not same thing, wouldn't it be better to be consistent with sum(number) ?
@Solenya.
@Solenya. Год назад
'n' is used as the variable within the sum() function itself. You can think of the sum(n) part as a blueprint. When the function is called, the compiler follows the blueprint by substituting 'number' everywhere there is an 'n'.
@Eleotblack
@Eleotblack 2 года назад
#include int factorial(int n); int main() { int number, result; printf("Enter the number: "); scanf("%d", &number); result= factorial(number); printf("facoria= %d", result); return 0; } int factorial(int n){ if(n > 0){ return n * factorial(n-1); } else{ return 1; } }
@sreyounprom
@sreyounprom Год назад
B . condition statement is used to prevent infinite recursive calls. and #include int factorialSum(int n); int main () { int number , result ; printf("PLease Enter the positive number :"); scanf("%d", &number); result = factorialSum(number); printf(" sum = %d", result); return 0; } int factorialSum(int n){ if(n != 0){ return n + factorialSum(n-1); } else { return 1; } }
@Zunxic
@Zunxic 2 года назад
First
@Zunxic
@Zunxic 2 года назад
And thanks for all the help!
@muhammedimran3538
@muhammedimran3538 2 года назад
we love u padma, ur gooooood
@anjarmaner3928
@anjarmaner3928 2 года назад
Greatt
@lukelombard92
@lukelombard92 Год назад
#include #include int computeFactorial(int number); int main() { int number; printf("Enter a number: "); scanf("%d", &number); printf(" The factorial of %d is %d.", number, computeFactorial(number)); return 0; } int computeFactorial(int number){ if(number == 1){ return number; } return number * computeFactorial(number - 1); }
@filmonmebrie460
@filmonmebrie460 Год назад
I don't understand why we return 1 in the last example why we don't return n as we did previously? Pls anyone break it down for me.
@AFCOE
@AFCOE Год назад
0! = 1 n+0= n
@hridhanpatel3987
@hridhanpatel3987 2 года назад
🔥🔥
@balashebjadhav977
@balashebjadhav977 Год назад
Answer is D
@furkanakdag7644
@furkanakdag7644 10 месяцев назад
Answer is "A"
@albertamenyah3019
@albertamenyah3019 Год назад
The answer is D.
@_.narr._.03
@_.narr._.03 2 года назад
Programming task: #include using namespace std; int factorial(int n); int main() { int num; coutnum; int result = factorial(num); cout
@elem3nt400
@elem3nt400 Год назад
bro its c++
@LogXTX
@LogXTX 2 года назад
Are you nepali ?
@stealthy_doctor
@stealthy_doctor 5 месяцев назад
wonderful video, programming task: #include #include int sum(int n); int main() { // Write C code here int number, result; printf("Enter a positive integer: "); scanf("%d",&number); result = sum(number); printf(" sum = %d", result); return 0; } int sum(int n){ if(n != 0 ){ //sum() function calls itself return n * sum(n-1); }else{ return n+1; } } and i think the answer to the quiz is d. none of the above?
@arjunkarthikeya4163
@arjunkarthikeya4163 2 месяца назад
Mama you can say DSA also no
@Salamanca-joro
@Salamanca-joro 7 дней назад
Mama?
@onic9623
@onic9623 Год назад
Option D : None Of The Above --------------------------------------------------------------------------- #include int factorial(int n); int main() { int num, result; printf("Enter A Number : "); scanf("%d", &num); result = factorial(num); printf("%d! = %d",num, result); return 0; } int factorial(int n) { if (n != 0) { return n * factorial(n-1); } else { return n+1; } }
@keshavdixit08
@keshavdixit08 2 года назад
D
@hvgamer0018
@hvgamer0018 Год назад
4
@nihatcanter4426
@nihatcanter4426 2 года назад
i didnt understand
@damiendawn567
@damiendawn567 Год назад
hardest video to understand between all the videos :(
@samuelwilkins2947
@samuelwilkins2947 Год назад
Her beauty distracts me alot😅
@akashmathdevru8618
@akashmathdevru8618 Год назад
programming task ( >_
@bibek_
@bibek_ 8 месяцев назад
Khate
@melikecakmak8909
@melikecakmak8909 Год назад
please don't say jero it's zero
@prabalslathia8680
@prabalslathia8680 Год назад
she has an accent. Stop shaming others. English is not everyone's first language.
@vinayakpotadar4907
@vinayakpotadar4907 5 месяцев назад
#include #include int fact(int f); int main() { int num1,result; printf("Enter the number for factorial : "); scanf("%d",&num1); result= fact(num1); printf("the factorial of %d is %d",num1,result); return 0; } int fact(int f) { if(f!=0) { return f*fact(f-1); } else return 1; }
@datuboharry6103
@datuboharry6103 Год назад
#include int factorial(int n); int main(void) { int input, result; printf("Input integer: "); scanf("%d", &input); result = factorial(input); printf("Result: %d", result); } int factorial (int n) { if (n != 1) { printf("%d times %d ", n, n-1); return n * factorial(n-1); } else } return n; } }
@JeongWoonKim-i4j
@JeongWoonKim-i4j Год назад
#include int main() { int number, result; printf("Enter a number greater than 0: "); scanf("%d", &number); result = factorial(number); printf("%d", result); return 0; } int factorial(int n) { if (n != 0) { return n * factorial(n-1); } else { return 1; } }
@oissimouni7726
@oissimouni7726 Год назад
#include int main() { int number,result; printf("Enter a positive number: "); scanf("%d",&number); result = fact(number); printf("the factorial is = %d ",result); return 0; } int fact(int n){ if (n>0) { return n * fact(n-1); } else{ return 1; } }
@hunter9544
@hunter9544 6 месяцев назад
#include int factorial(int n); int main() { // Write C code here int number; int answer; printf("Enter a positive integer: "); scanf("%d", &number); answer=factorial(number ); { printf("factorial = %d", answer); } return 0; } int factorial(int n) { if (n!=0) { return n * factorial(n-1); } else { return 1; } } Arise
@aboutouruniverse3834
@aboutouruniverse3834 Год назад
// Online C compiler to run C program online #include int sum (int n); int main() { int number; int result; printf("enter number: "); scanf("%d", &number); result = sum(number); printf("sum = %d", result); return 0; } int sum(int n){ if (n > 0){ return n * sum(n-1); } else{ return 1; } } number 5 output = 120
@VictoriaOtunsha
@VictoriaOtunsha Год назад
#include #include int fact(int n); int main (){ int num, result; printf("Enter a number: "); scanf("%d", &num); result = fact(num); printf("%d", result); return 0; } int fact(int n){ if(n != 0){ return n * fact(n-1); } else { return n+1; } }
@haxurn-h4l
@haxurn-h4l Год назад
#include int mul(int n); int main(){ int num, result; printf("Enter Positive integer number here: "); scanf("%d", &num); result = mul(num); printf("Factorial: %d", result); return 0; } int mul(int n){ if(n > 0){ return n * mul(n-1); } else{ return 1; } }
@ryanranjith672
@ryanranjith672 Месяц назад
# include int a(int b); int main() { int c,d; printf("Enter any number"); scanf("%d",&c); d = a(c); printf("The result is %d", d); return 0; } int a(int b ){ if (b >0){ return b * a(b-1); } else{ return 1; } }
@keshavdixit08
@keshavdixit08 2 года назад
// Online C compiler to run C program online #include int fac(int n); int result; int main() { int number; printf("Enter a postive integer = "); scanf("%d",&number); result = fac(number); printf(" Result = %d ",result); return 0; } int fac(int n) { if (n > 0) { return n * fac(n-1); } else { return 1; } }
@dharmendrasinghchaudhary4177
@dharmendrasinghchaudhary4177 2 года назад
// To find the factorial of the given number entered by the user #include int factorial(int x ); int main(){ int n; printf("Enter a number :"); scanf("%d",&n); printf("The factorial of the given number is :%d",factorial(n)); return 0; } // Function to find factorial int factorial(int x){ if(x == 0 || x == 1){ return 1; } int fact = x * factorial(x-1); return fact ; }
@praneethbolla3449
@praneethbolla3449 3 месяца назад
#include int sum(int n); int main() { int number,result; while (1){ printf("Enter a positive Intger:"); scanf("%d",&number); result =sum(number); printf("sum:%d ",result); } return 0; } int sum(int n){ if(n !=0){ return n * sum(n-1); } else{ return 1 ; } }
@Jimmy12X91
@Jimmy12X91 10 месяцев назад
#include int factNum(int n); int main () { int num, result; printf ("Enter an integer: "); scanf ("%d", &num); result = factNum(num); printf ("Sum = %d", result); return 0; } int factNum(int n) { if (n != 0) { return n * factNum(n-1); } else { return 1; } }
@chetanwani5714
@chetanwani5714 Год назад
#include int fact(int n); int main() { int n, f; printf("Enter a number: "); scanf("%d", &n); f= factorial(n); printf("Factorial is: %d", f); return 0; } int factorial(int a){ if (a > 0){ return a * factorial(a-1); } else { return 1; } }
@tanishka7278
@tanishka7278 2 года назад
Please finish this course soon
@dnwint2
@dnwint2 5 месяцев назад
D
@YUPENGMA-h1y
@YUPENGMA-h1y Год назад
#include int multiplied(int n); int main(){ int number, result; printf("Enter a number: ",number); scanf("%d",&number); result = multiplied(number); printf("multiplied = %d", result); return 0; } int multiplied(int n){ if(n > 0){ return n * multiplied(n-1); } else{ return 1; } }
@vintrixtergunot8064
@vintrixtergunot8064 4 месяца назад
#include int product (int n); int main() { int number; printf ("Input Number: "); scanf ("%d", &number); int result = product (number); printf("The factorial of %d is %d", number, result); return 0; } int product (int n){ if (n > 0){ return n * product (n-1); } else{ return 1; } }
@JASMIN-jg2vn
@JASMIN-jg2vn 4 месяца назад
#include int factorial(int n); int main() { int number, result; printf("Enter a number: "); scanf("%d", &number); result =factorial(number); printf("Factorial of %d = %d ", number, result); return 0; } int factorial(int n) { if (n > 0) { return n * factorial(n-1); } else { return 1; } }
@navnav1819
@navnav1819 Год назад
D
@assimboutahar1163
@assimboutahar1163 Год назад
#include int factorial(int n); int main(){ int number; printf("enter a number: "); scanf("%d ", &number); int result = factorial(number); printf("the result= %d", result); return 0; } int factorial(int n) { if (n > 0){ return n * factorial(n - 1); } else { return 1; } }
Далее
#19 C Arrays | C Programming For Beginners
13:27
Просмотров 260 тыс.
Recursion in C
11:12
Просмотров 932 тыс.
#15  C Functions | C Programming for Beginners
17:21
Просмотров 219 тыс.
5 Simple Steps for Solving Any Recursive Problem
21:03
Recursion | C Programming Tutorial
10:49
Просмотров 28 тыс.
#23 C Pointers | C Programming For Beginners
11:01
Просмотров 140 тыс.
Learn RECURSION in 5 minutes! 😵
5:59
Просмотров 164 тыс.
#21 C Strings | C Programming For Beginners
10:13
Просмотров 139 тыс.