Easy to learn C language Chapter 1

Knowledge points about C language

1. The C language is concise, compact, easy to use and flexible. ANSI C has only 32 keywords in total

32 keywords: (defined by the system, cannot be redone for other definitions) auto break case char const continue default do double else enum extern float for goto if int long register return short signed sizeof static struct switch typedef unsigned union void volatile while

Turbo C has expanded 11 keywords: asm _cs _ds _es _ss cdecl far huge interrupt near pascal

Special note: Note: In C language, keywords are all lowercase.

2. C language has 9 kinds of control statements, if( )~else~ for( )~ while( )~ do~while() continue break switch goto return

3. C language has 34 operators:

Arithmetic operators: +-* /% ++ -

Relational operator: <<= ==> >= !=

Logical Operators:! && ||

Bitwise operator: << >> ~ | ^ &

Assignment operator: = and its extension

Conditional operator: ?:

Comma operator:,

Pointer operator: * &

Find the number of bytes: sizeof

Force type conversion: (type)

Component operator:. ->

Subscript operator: []

Other: ()-

4. Write a simple C program

#include <stdio.h> 

void main() 

{ 

        printf(“Hello Word!.\n”); 

}

Small exercise: input two integers from the keyboard and output the larger number

#include <stdio.h>
void main()
{     int max(int x,int y)
      int a,b,c;
      scanf(“%d,%d”,&a,&b);
      c=max(a,b);
      printf(" max = %d",c);
}
int max(int x,int y)
{   int  z;
    if(x>y) z=x;
         else z=y;
    return(z);
}

5. Computer steps of C program

Edit -> Compile -> Link -> Execute

Edit: input program code, generate source program *.c

Compilation: grammatical analysis and error checking, translation to generate target program *.obj

Link: Link and assemble with other target programs or libraries to generate executable program *.exe

Guess you like

Origin blog.csdn.net/weixin_41987016/article/details/105818338