From ee4b5944d5b2e9d560f8f45db5858431d579f708 Mon Sep 17 00:00:00 2001 From: Vaibhav <116552237+vabsinc@users.noreply.github.com> Date: Tue, 25 Oct 2022 21:48:45 +0530 Subject: [PATCH 1/2] Instructions for this directory. --- C/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 C/README.md diff --git a/C/README.md b/C/README.md new file mode 100644 index 0000000..cb4f7b7 --- /dev/null +++ b/C/README.md @@ -0,0 +1,15 @@ +[//]:: (Start of README with a markdown comment.) +# Here Are The C Codes + +---- + +- Use this **[link](https://www.programiz.com/c-programming/online-compiler/)** to run *c codes*. +- code ***main-recursion.c*** is a program which use main() function. +- `main()` function used for recursive calls. +- print `hello` till user enter commands to execute. +- it will exit the code when `entered 0` for exit. +- don't use values other than `integers`. + +---- + +[//]:: (End of README with a markdown comment.) From 5f5bef27c8f22f761ac28458df6593dd843d5a01 Mon Sep 17 00:00:00 2001 From: Vaibhav <116552237+vabsinc@users.noreply.github.com> Date: Tue, 25 Oct 2022 21:52:27 +0530 Subject: [PATCH 2/2] recursion without function using default of c --- C/recursion-with-main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 C/recursion-with-main.c diff --git a/C/recursion-with-main.c b/C/recursion-with-main.c new file mode 100644 index 0000000..1fd62f8 --- /dev/null +++ b/C/recursion-with-main.c @@ -0,0 +1,17 @@ +#include +int main() +{ + int a; + printf("Enter command ::: "); + scanf("%d",&a); + if (a) { + printf("hello\n"); + // Here's comes the recursive calls. + main(); + } + // Here's comes the recursive exit. + // Recursion without exit isn't good practice. + // No one wants infinite calls. + else printf("Exit"); + return 0; +}