C Programming

Embed Size (px)

Citation preview

C ProgrammingClick to edit Master subtitle style

Chaluemwut N.

C 1970: B Ken Thompson 1972: C Dennis Ritchie 1983:ANSI C Bell Labs

Cmain() { printf("Hell World"); }hello.c

compile hello.c exe file

C with eclipse

Project C

Project C

Project C

Run Program

run program

main { // printf(test ); }

Program Hello World printf

-1 : Program program Hello World printf main(){ printf("Hello World"); }

- 1

Variables Click to edit Master subtitle style

ram (Data Type), (Variable Name) Data Type Variable Name

int numItem; float a; char name[10] = test;

printf printf %d

main(){ int a = 10; printf("number is %d",a); }

printfmain(){ printf("line1\n"); printf("line2\n"); printf("line3"); } printf \n

vs 1, 2, 3, 4 1.0, 1.10, 2.1 main(){ printf("5/2 : %d\n", 5/2); printf("5/2.0 : %f",5/2.0); }

scanf main(){ int a; scanf("%d",&a); printf("a is : %d", a);

Click to edit Master subtitle style

C +, -, * , /

main(){ printf("4+2 = %d\n",4+2); printf("4-2 = %d\n",4-2); printf("4*2 = %d\n",4*2); printf("4/2 = %d\n",4/2); }

-3.1 4 ( = pi*r*r, pi=3.141)

(Arithmetic Operator)

-3.2 3.1 = 2*PI*r

BMI =

-3.2 3.1 = 2*PI*r

BMI =

(Relational Operators) 5 > 10 3 < 6

operator true() false()

(Relational Operators)

(Logical Operators)

(Logical Operators)

Control structuresClick to edit Master subtitle style

Control structures Selection control structures if if-else

Iteration control structures for while

ifif(a>0){ printf("a>0"); }

: 4-1 2 1 2 1

main(){ int a,b; scanf("%d",&a); scanf("%d",&b); if(a>b){ printf("a is : %d",a); } }

: 4-1 :

> 80 : A 70