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.) 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; +}