Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
CpointfunProd
//gcc 7.4.0 //write a function that returns product of n values f(1), f(2).....f(n) //this code is created by Rezaul Hoque on June 02,2021 //please contact at jewelmrh@yahoo.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <stdio.h> int p(int (*)(int), int); int square(int); int sum(int); //the product function ,p,evaluates the function to which pointF points at each value of i and returns product of these n-values int p(int (*pointF)(int m), int n) { int prod= 1; for(int i=1; i<=n; i++) prod *= (*pointF)(i); return prod; } int sum(int b) { return (b+b); } int square(int b) { return (b*b); } int main () { printf("%d\n",p(sum,3));//it returns prod of sum(1) * sum(2)*sum(3) printf("%d\n",p(square,3));//it returns product of square(1)*square(2)*square(3) return 0; }
run
|
edit
|
history
|
help
0
Print Micro Seconds
variable number of arguments 3
Practica 5 fibonacci
B_141125_MenorMayor
Sum Two Numbers
pthread_monte_carlo_pi.c
sample.c
upper case letter.c
B_141121_factorial01
sum of arrays