Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write programs with pointers in C language

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report