Showing posts with the label Recursive Functions in C Langauge


A function is generally call another function to accomplish the task but sometimes a function can call itself to complete the task. This type of function is known as a recursive function and this feature is known as recursion. Let's take a short example of the recursive function.main(){ printf("Hello"); main(); }In the above program snippet main() function calls itself so main() is known as recursive function but the output of the above program snippet is "hello" prints indefinitely. The following program snippet improve the above logic and try to make it finite. main() { int i=1; if(i<=10) { printf("Hello"); i++; main(); } } If you thought that above logic print "Hello" 10 times then you are wrong because when program start i becomes one and of course the condition gets true and "Hello" gets printed then i becomes 2 by increment and then the main() function is again called. As the main()…

Popular posts from this blog

Program to calculate telephone bill

Arrays in C Language

String in golang

Sum of two numbers in go lang

Pointers in C Language

Decision Making Statements

Say Hello world in Go lang

Decision Making in Go lang

Program to convert time from seconds to hours, minutes and seconds

Installing go lang