Call of a function without Parameters

Source: Internet
Author: User

When writing a program, sometimes a relatively independent program segment will be used multiple times to achieve the desired function. In this case, we can take this program segment out separately and use it as a separate function.

For example, we want to print the image

 

Looking at the graph, we can see that the program that appears in the stars will certainly appear twice. We can take this program out separately and use it as a separate function call.

Source program:

# Include <stdio. h>

Star () // The function header can be defined at will, but you 'd better know what functions you want to implement at first glance.


{

Int I, j;

For (I = 1; I <= 4; I ++)

{// What is the execution process of the program with multiple functions? This type of program is always executed from the main function.


When the for (j = 1; j <= I; j ++) number is used, it is executed in the called function body.


Printf ("*");

Puts ("");


}

Return; // when the return statement is executed in the called function, it is returned to the main function for further execution.


}

Main ()

{

Puts ("The first one :");

Star ();

Puts ("The second one :");

Star ();


}

The result is the figure above!


 

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.