Introduction to the function of C language

Source: Internet
Author: User

Introduction to Functions

Problems encountered:

1. The code looks very much, not concise

2. The change is very troublesome, need to all use of place to revise

function can solve these two problems

Function can be understood as a packing belt, that is, to package a piece of code, when used, just write the name of the packing belt.

Classification of functions:

1. Functions without parameters and no return value

2. Function with parameters

3. Functions with Return values

The definition syntax for a function without a parameter without a return value:

void function name () {

function body;

}

Meaning: The function name is your own name, but to conform to the identifier specification:

1. To make a name meaningful, you have to know what you mean by looking at it.

2. Only the following lines, letters, and $, followed by underscores, numbers, letters,

3. Cannot use keywords as names

4. Observe the Hump naming method: First letter lowercase, each subsequent word capitalized

The function body is the code to be packaged

Call syntax for the function:

The call means that you need to use this bundled code somewhere.

Grammar:

function name ();

Example: Drawheart ();

Tips: Code examples are as follows

#include <stdio.h>

void Drawheart () {

printf ("Hibiscus, 5201314\n");

printf ("* * * * * * *****\n");

printf ("********* *********\n");

printf ("************ ************\n");

printf ("***************************\n");

printf ("***************************\n");

printf ("***************************\n");

printf ("*************************\n");

printf ("*********************\n");

printf ("*****************\n");

printf ("*************\n");

printf ("*********\n");

printf ("*****\n");

printf ("***\n");

printf ("*\n");

}

int main (int argc, const char * argv[]) {

Drawheart ();

return 0;

}

Introduction to the function of C language

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.