Get the App
SLTechnology News&Howtos  ›  Development  › 

How to write programs with pointers in C language

Shulou Source: shulou.com Published: 2022-06-03 05:02:50 09月21日 Update

What this article shares with you is about how C language uses pointers to write programs. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it with the editor.

Topic requirement

Using the pointer to write a program, using the trapezoid method to calculate the definite integral in the following formula:

Reference code

First of all, explain the use of pointers: because the parameters passed are numeric, there is no need to use pointers to improve efficiency, so pointers are used here to point to functions.

Notice this statement in the calc () function:

Double (* pfunction) () = & function

That is, the process I have described has been realized.

The code is as follows:

# include # include double function (double x) {return (double) (pow (XMagol 3) + x double ha 2 + 1);} double calc (double a, double b) {double ha, hb, result=0; int i; double (* pfunction) () = & function; for (iS0; I

Tags: Pointers programs languages codes functions more knowledge articles practicality precision formulas parameters actually that is work meeting gap pointing efficiency number quantity Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MySQL Shulou Technology Shulou Information Shulou Tech Info