编程知识 cdmana.com

C language learning lesson 1

One 、 Preliminary code :

#include <stdio.h>

int main(){
    printf(
            "Hello world\n"
            "Hello world\n"
           );
    return 0;
}

Print the results :

Hello World It's a visible character .

\n It's the escape character .

 

Two 、

C Language -> assembly language -> machine language ->cpu perform Compiler language

Python-> Bytecode -> The interpreter explains ->cpu perform

C High language efficiency , High flexibility , High portability .

 

3、 ... and 、 Variable

The meaning of variable is to determine the target and provide storage space .

Variable names can only be in English letters (A-Z,a-z) And number (0-9) Or underline (_) form .

The first letter must start with a letter or an underline .

Variable names are case sensitive .

You cannot use keywords to name variables .

 

Four 、 keyword

Conventional c Language has 32 Key words

 

char- Character , Take up one byte . -char a

int- integer , It usually reflects the most natural length of the certificate in the machine used - int a

float- Single precision floating point float c

double- Double precision floating point double d

//#include <stdio.h>
//
//int main(){
//    printf(
//            "Hello world\n"
//            "Hello world\n"
//           );
//    return 0;
//}

#include <stdio.h>
int main() {
    int a;
    char b;
    float c;
    double d;
    a = 520;
    b = 'F';
    c = 3.14;
    d = 3.141592653;

    printf(" fish C The studio was founded in 2010 Year of %d\n", a);
    printf("I love %cishC.com!\n", b);
    printf(" PI is :%.2f\n", c);
    printf(" Accurate to the decimal point 9 The Pi of bit is :%11.9f\n", d);
    return 0;
}

fish C The studio was founded in 2010 Year of 520
I love FishC.com!
PI is :3.14
Accurate to the decimal point 9 The Pi of bit is :3.141592653

%d Substitute integer   %c Alternate characters   %.2f yes For decimals 2 Two decimal places    %11.9f Represents a total of 11 position , There is... After the decimal point 9 position .

 


 

 

 

版权声明
本文为[Life's in danger]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/01/20210131224824841o.html

Scroll to Top