Basic knowledge of C language

Source: Internet
Author: User

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

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.