This commit is contained in:
2025-05-23 03:26:13 +03:00
parent 191705c1dc
commit 4e9b002e99
14 changed files with 307 additions and 0 deletions

25
DeitelC/Chapter6/facto.c Normal file
View File

@ -0,0 +1,25 @@
#include <stdio.h>
#define SIZE 6
int whatIsThis(const int b[], size_t p);
// function prototype
// function main begins program execution
int main(void)
{
int x; // holds return value of function whatIsThis
// initialize array a
int a[SIZE] = {1, 2, 3, 4, 5, 6};
x = whatIsThis(a, SIZE);
printf("Result is %d\n", x);
}
// what does this function do?
int whatIsThis(const int b[], size_t p)
{
// base case
if (1 == p)
{
return b[0];
}
else { // recursion step
return b[p - 1] * whatIsThis(b, p - 1);
}
}