Hello Sir; I've beening following ur Lectures on YouTube But I've Gotten Stuck Here on this lecture 9 my compiler is returning an error message : 'SUM' is asigned a value which is never used ? Please help me here my compiler is not recognizing 'n'
Hello Sir; I've beening following ur Lectures on YouTube But I've Gotten Stuck Here on this lecture 9 my compiler is returning an error message : 'SUM' is asigned a value which is never used ? Please help me here my compiler is not recognizing 'n'
As a tack on to my prior statement (I ran out of room). This appears very similar to recursion because in fact it is. If it helps try imagine little Russian dolls in succession and if that helps here is a quote from "Back to the Future":
This appears very similar to recursion as the function is calling it's self. All though it is true that the function is passing n-1 into its self on the in function call in the new call that is treated the same way as n would be and that is where the increment is happening. The part that allows it not to run infinitely is the if statement at the top of the function searching for when n is o at which point it returns 0 and then terminates the original call and all subsequent calls.
hey im watching these vids out of casual intrest, and ive got a set up which allows me to write and compile my own c programs. i was just wondering if anyone had any tips on how to do the assignment 'bjorn'. i dont understand how to use a recurring function, but get word 'p' printed when number 'p' is inputted. any help would be greatly apreciated. feel free to pm me.
Afraid I don't know what is required in the bjorn assignment, but I'll give you an example of what a recurring function is with a function (which I've called recurringFunction for this example) that will repeat a set number of times (from an input value to a variable I'm calling amountRecurring, which you've already learned how to do if you've followed along):
@theseriousaccount What nateaus said (while highly compiler dependent) makes more sense, as one can get a look at everything going on before termination. But yeah I just pulled that horrible fail of an example I posted nearly a year ago out; there is a better one in this video. ^.^
Actually this is not recursion. Your example is just repeatedly calling a function.
Recursion is when a function calls itself. But the self-call needs to modify the n value. Eg n-1 or n+1, so each subsequent call modifies the n value and moves closer to the final output. Otherwise there would be an endless loop.
If you look at 29:43 you will see the function calls itself with but with (n -1).
I think he actually wrote all the numbers from 1 to 100, and then all over again backwards under the previous one. He then saw they all added up to 101, multiplied, then divided. So I don't think it was THAT awfully quick, but still rather impressive. That's what it says in this book I'm reading at the moment, called "The Language of Mathematics" by Keith Devlin. Fun read btw. Doesn't teach you math, but it gives you some history and insight. It even scratches topology. Math is damn cool.
Waste of time.
OldGhostsGoHome 1 month ago
I'll follow every lecture he says.
jhamien920 2 months ago
This has been flagged as spam show
Hello Sir; I've beening following ur Lectures on YouTube But I've Gotten Stuck Here on this lecture 9 my compiler is returning an error message : 'SUM' is asigned a value which is never used ? Please help me here my compiler is not recognizing 'n'
sum = n + sumToN (n-1);
Izooify 4 months ago
Hello Sir; I've beening following ur Lectures on YouTube But I've Gotten Stuck Here on this lecture 9 my compiler is returning an error message : 'SUM' is asigned a value which is never used ? Please help me here my compiler is not recognizing 'n'
Izooify 4 months ago
@Izooify he is not personally seeing the comments now is he
muqeet92 1 month ago
As a tack on to my prior statement (I ran out of room). This appears very similar to recursion because in fact it is. If it helps try imagine little Russian dolls in succession and if that helps here is a quote from "Back to the Future":
"you're not thinking fourth dimensionally"
Love Victor Cross
dokeydummer1 4 months ago
Dear nateaus.
This appears very similar to recursion as the function is calling it's self. All though it is true that the function is passing n-1 into its self on the in function call in the new call that is treated the same way as n would be and that is where the increment is happening. The part that allows it not to run infinitely is the if statement at the top of the function searching for when n is o at which point it returns 0 and then terminates the original call and all subsequent calls.
dokeydummer1 4 months ago
@nateaus
Interesting. I thought recursion when a method calls itself regardless of any counting mechanism.
ASeventhSign 9 months ago
2 people took fiddling the wrong away and ended up in prison
porkinmycorkhole 1 year ago 2
i wish my lecturers were like him
AlmightyDemon 1 year ago
microsoft security? i don't get it
intindse 1 year ago 3
@intindse Microsoft doesn't too.
markovcd 9 months ago
-Wall or -Wuninitialized will not warn you for uninitialized variables if you do not use -O with them.
tiftik 1 year ago
I only wish he didn't talk so fast
diegoramos27 1 year ago
man! this guy is good! I wish my uni was like this. here in melbourne most uni's dont have great staff these days, unless you're in the best uni.:(
Oh well, teaching myself..
puneetinc 2 years ago 2
His shirt, "Microsoft security". Ha.
SauronsEye 2 years ago 7
hey im watching these vids out of casual intrest, and ive got a set up which allows me to write and compile my own c programs. i was just wondering if anyone had any tips on how to do the assignment 'bjorn'. i dont understand how to use a recurring function, but get word 'p' printed when number 'p' is inputted. any help would be greatly apreciated. feel free to pm me.
misio129 2 years ago
Afraid I don't know what is required in the bjorn assignment, but I'll give you an example of what a recurring function is with a function (which I've called recurringFunction for this example) that will repeat a set number of times (from an input value to a variable I'm calling amountRecurring, which you've already learned how to do if you've followed along):
Truthiness231 2 years ago
Comment removed
Truthiness231 2 years ago
Comment removed
Truthiness231 2 years ago
thanks, all that is a great help!
misio129 2 years ago
Np ^.^
Truthiness231 2 years ago
Or just press "Ctrl C" to manually break the loop ; ).
nateaus 2 years ago
@Truthiness231 well that's a bit extreme, killing the program works too...
theseriousaccount 1 year ago
@theseriousaccount What nateaus said (while highly compiler dependent) makes more sense, as one can get a look at everything going on before termination. But yeah I just pulled that horrible fail of an example I posted nearly a year ago out; there is a better one in this video. ^.^
Truthiness231 1 year ago
Actually this is not recursion. Your example is just repeatedly calling a function.
Recursion is when a function calls itself. But the self-call needs to modify the n value. Eg n-1 or n+1, so each subsequent call modifies the n value and moves closer to the final output. Otherwise there would be an endless loop.
If you look at 29:43 you will see the function calls itself with but with (n -1).
nateaus 2 years ago 7
@nateaus In other words, they shouldn't have called the movie inception, they should have called it recursion.
wikiemol2 1 month ago
Brining a chainsaw to an exam... NOW THATS AN IDEAR
andrewredss 2 years ago 2
they didnt laugh at his mars bar joke!
kohehd 2 years ago
I think he actually wrote all the numbers from 1 to 100, and then all over again backwards under the previous one. He then saw they all added up to 101, multiplied, then divided. So I don't think it was THAT awfully quick, but still rather impressive. That's what it says in this book I'm reading at the moment, called "The Language of Mathematics" by Keith Devlin. Fun read btw. Doesn't teach you math, but it gives you some history and insight. It even scratches topology. Math is damn cool.
eedahl 3 years ago 2