0

#include <stdio.h> int call(int (*func)(int),int arg) { return func(arg); } int inc(int var) { return ++var;}

Please correct this

16th May 2022, 4:26 AM
Ashutosh Kumar
3 odpowiedzi
+ 1
Thnx bro
16th May 2022, 4:53 AM
Ashutosh Kumar
0
include <stdio.h> int main(){ int call(int (*func)(int),int arg) { return func(arg); } int inc(int var) { return ++var;} printf("%d\n", call(inc, 2)); printf("%d\n", call(inc, 5)); return 0; }
16th May 2022, 4:42 AM
Bob_Li
Bob_Li - avatar
0
1. int call() is a function that takes a function and an int as arguments. 2. int inc() is a function that adds 1 to it's argument. 3. use int call() to run int inc() you are not getting anything because you must run these inside the int main() function and you have to print the result. you are doing higher-order functions but you are ignoring the basics.
16th May 2022, 4:46 AM
Bob_Li
Bob_Li - avatar