Hello World
Include file contains commands
<stdio.h> head File/First file
the int main () declares that a name is main, and the type is a function of shaping,
This part is called the function Head section in the function, and there is a main function in each program
The main function is the entry part of a program.
{......} : function Body
Return the end flag of the main function, according to the function header section of the request, the returned data needs to be a shaping data.
/* * * Comment
#include <stdio.h>int main () {printf ("Hello, world! I ' m coming!\n"); return0;}
First Small program
#include <stdio.h>/*Include header file*/#defineHeight 10/* Define Constants */intCalculateintLong,intWidth);/*function Declaration*/intMain ()/*Main function*/{intM_long;/*define shaping variables, representing length*/ intM_width; intResult/*define shaping variables, representing volume*/printf ("the height of the rectangle is:%d\n", Height);/*Show Hints*/printf ("Please enter the length \ n"); scanf ("%d", &m_long);/*Input Length*/printf ("Please enter the width \ n"); scanf ("%d",&m_width); Result=calculate (M_long,m_width);/*call function, calculate volume*/printf ("the volume of the box is:"); printf ("%d\n", result); return 0; } intCalculateintLong,intWidth);/*define the calculation volume function*/{intresult=long*width*Height; returnResult/*returns the calculated volume result*/}
Code Execution procedures
1. Start
Include header file = = "Define constant = =" function declaration = = " Enter main function main = =" program End
2. Main function body
Define REQUIRED variable = = "Display message = =" Input calculation condition = = "Calculates the volume of the box and calls the Calculate function.
3. Calculate function Body
Executes the function body code, calculates the result and returns it.
A different place than Python.
#define Height #define定义了一个符号Height, the height in this program represents 10.
int calculate (int Long,int Width); Function declaration, to prepare for the use of the function below.
int m_width; Define variables to prepare for the use of variables.
scanf ("%d", &m_long); Enter the statement, &m_long store the input information.
Summarize:
C programs start with the main function, regardless of where they are placed.
C program is not case-sensitive
Each execution statement is ";" End
Basic knowledge of C language