Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
CpointfunProd
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//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; }
gcc
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 0.32 sec, absolute running time: 0.15 sec, cpu time: 0 sec, memory peak: 5 Mb, absolute service time: 0,55 sec
edit mode
|
history
|
discussion
48 36