What are the functions to be used in C

Updated on technology 2024-02-08
6 answers
  1. Anonymous users2024-02-05

    I majored in computer science, and I was embarrassed when I first learned C language, but I also had some experience.

    Language this kind of thing will naturally be all over with more contact, it takes time, take your time, take your time, see the questions you asked me as if I were at the beginning, I feel that you are learning fragmented, I suggest that you learn C language systematically, I have a C language tutorial, txt, I can send it to you, see how helpful, you ask these questions, even if you pass it is not thorough.

    Functions contain the executable nature of the program. The entry and exit of each C program is located in the main() function. The main() function can call other functions, and after these functions are executed, the program's control is returned to the main() function, and the main() function cannot be called by other functions.

    Usually we call these called functions lower-level functions. When a function call occurs, the called function is executed immediately, while the caller enters a waiting state until the called function is executed. Functions can have arguments and return values.

    Programmers tend to treat functions as "black boxes" and don't care about the details of their implementation. Of course, programmers can also develop their own libraries.

    To clarify, the section on functions is very important, and it can be said that the advantages and disadvantages of a program are concentrated in the functions. If the function is used properly, it can make the program look organized and easy to understand. If the functions are used in a mess, or if the functions are not used, the program will look very messy, not only so that others can't see it, but even you will be easily confused.

    Suffice it to say, if a program with more than 100 lines doesn't use functions, then the program must be wordy (some absolutely, but also true).

    1. Definition of function.

    A function consists of two parts: a function header and a statement body.

    The function header consists of the following three parts:

    The type of value returned by the function.

    The name of the function. Parameter table.

    A complete function should look like this:

    Function Return Value Type Function name (parameter table).

    sentence body; The function return value type can be a data type, or a pointer to a data type, a pointer to a structure, or a pointer to an array. The pointer concept will be introduced later.

    The function name must be unique within the program, and it also follows identifier naming conventions.

    There can be no parameter table or multiple parameters, and the actual parameters will be copied to these variables when the function is called. The body of the statement includes the declaration and executable of local variables.

    We've already touched on functions like abs(), sqrt(), and we don't know what's inside it, we just need to use it.

    This section focuses on function calls with no parameters and no return value.

  2. Anonymous users2024-02-04

    c, what are you dealing with? If you want to use system-defined functions, it is recommended that you buy a book like the Functions Encyclopedia. You can also customize the function to rewrite it like you did on the second floor.

  3. Anonymous users2024-02-03

    In C, the types of functions can be divided into the following types:

    1.Functions without return values without parameters: These functions do not need to pass arguments or return values, and they usually define some actions or statements that perform certain actions. The format of the function definition is: void Function name ().

    2.Parameterless functions with return values: These functions do not need to pass parameters, but they need to return a value, which is usually used to calculate a value and return the result. The format of the function definition is: Data Type Function name ().

    3.Functions with return values and parameters: This type of function needs to pass one or more parameters and return a value, which is usually used to complete some operation that calculates the result based on the input parameters. The format of the function definition is: Data Type Function Name (Parameter List).

    4.Functions with no return value: This type of function needs to pass one or more parameters, but does not need a return value, and is usually used to complete some operations to modify the state of the program, such as changing global variables.

    The format of the function definition is: void function name (parameter list).

    In the C language, the choice of function type depends on the specific needs and usage scenarios of the function, and different types of functions can be selected for development according to your needs. It should be noted that when developing functions, it is necessary to comprehensively consider the function, input parameters, and return values of functions to avoid program errors or non-compliance with design requirements.

  4. Anonymous users2024-02-02

    C functions are a basic program segment with strict syntax rules:

    The syntax of the pure function definition in C is as follows: The return type, function name, and parameter list of the function definition must be consistent with the function declaration.

    Some books inexplicably categorize functions into library functions and custom functions. There is really no difference between the two functions.

    For example, how do you classify the functions in the library that you wrote?

    Therefore, from the perspective of the actual C language, there are only two types of functions to do jujubes:

    1. Ordinary functions.

    2. Inline functions.

  5. Anonymous users2024-02-01

    There are two types of functions in the C language: library functions and user-defined functions.

  6. Anonymous users2024-01-31

    The two are actually no different, so don't force it to be classified, all functions are the same.

Related questions
9 answers2024-02-08

Scope. You static char *chh;

static char *ch1;Although the address pointed to by the two pointers does not change, have you ever wondered whether the memory address they point to has been released, char chc[10]; It's local, the function is out, the lifecycle is over, and you're trying to access it with a pointer in void times(). >>>More

4 answers2024-02-08

The clouds go down the mountain, but the ground is not dry. >>>More

4 answers2024-02-08

It's not very hard that the tail node next points to null. >>>More

10 answers2024-02-08

It's a shame to ask your question, one is the development environment, the other is the language, what's the difference, you're laughing to death.

9 answers2024-02-08

It should be 0It should be a remainder operation.