Input: N = 10
Output: 10 9 8 7 6 5 4 3 2 1
Input: N = 5
Output: 5 4 3 2 1
- Use static variable to initialise the given number N.
- Print the number N and decrement it.
- Call the main() function recusrsively after above step.
Below is the implementation of the above approach:
10 9 8 7 6 5 4 3 2 1
Time Complexity: O(N), where N is the given number.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Is it fine to write "void main()" or "main()" in C/C++?
- Difference between "int main()" and "int main(void)" in C/C++?
- C/C++ program to print Hello World without using main() and semicolon
- What does main() return in C and C++?
- Can main() be overloaded in C++?
- Executing main() in C/C++ - behind the scene
- How can we write main as a class in C++?
- Functions that are executed before and after main() in C
- return statement vs exit() in main()
- How to change the output of printf() in main() ?
- How to write a running C code without main()?
- Print "Hello World" with empty or blank main in C++
- How to print "GeeksforGeeks" with empty main() in C, C++ and Java?
- How to call some function before main() function in C++?
- Calling virtual methods in constructor/destructor in C++
- C program to print a string without any quote (singe or double) in the program
- C Program for Program to find area of a circle
- Hello World Program : First program while learning Programming
- C program to detect tokens in a C program
- Lex Program to remove comments from C program
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.