C programming
This presentation is the property of its rightful owner.
Sponsored Links
1 / 77

C Programming PowerPoint PPT Presentation


  • 62 Views
  • Uploaded on
  • Presentation posted in: General

C Programming. Visual C++. Week 1. Preprocessor Directive. Commen t. Variable. cout cin. Week 2. Operators (ตัวดำเนินการคณิตศาสตร์). ตัวดำเนินการเพิ่ม/ลด ตัวแปร. ข้อมูลชนิด Character. การใช้คำสั่ง t และ . Week 3. การวน Loop โดยใช้คำสั่ง For. Week 4.

Download Presentation

C Programming

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


C programming

C Programming

Visual C++


C programming

Week 1

  • Preprocessor Directive

  • Comment

  • Variable

  • cout cin


C programming

Week 2

  • Operators()

  • /

  • Character

  • \t \n


C programming

Week 3

  • Loop For

Week 4

  • Loop While

  • dowhile


C programming

Week 5

  • 1

Week 6

  • if..else

  • if.else if else

  • switch case


C programming

Week 7

  • Character

  • \t \n

  • Array

Week 8

  • Function


C programming

Week 9

Week 10

  • Visual C++ 6

  • C OOP

  • Class & Object

  • Visual C++ 6


C programming

Week 11

  • Control Static

  • CFont

  • CButton

  • Message Map


C programming

Week 12

  • Class CScrollBar

  • CEdit ()

  • CListBox

  • CComboBox


C programming

Week 13

  • Resource Script

  • Icon

  • Menu

  • Dialog (CDialog)

  • Hotkey


C programming

Week 14

  • 2

Week 15

  • Appwizard

  • Dialog - Bassed

  • Classwizard

  • Textbox


C programming

Week 16

Week 17

  • Check Box

  • ListBox

  • Radio Box

  • Combo Box

Week 18


C programming

  • 60

  • - 20

  • - 20

  • - 10

  • - 10

  • 40

  • - 20

  • - 10

  • - 10

  • 100


C programming

C

C

UNIX Assembly

H/W

C H/W


C programming

.. 1972 Dennis Ritchie B BCPL .. 1978 Brain Kernighan

Dennis Ritchie K&R

(Kernighan & Ritchie) The C Programming Language


C programming

()

.. 1988 Kernighan & Ritchie ANSI(American National Institute) ANSI C

(middle-level-language) (Structured Programming) C++, Perl , Java , C#


C programming

C

  • C H/W

  • Function


C programming

MUL R1, D

STO R1, TEMP1

LOD R1 ,B

ADD R1,TEMP1

11001010 10011001

00100110 11001011

01001101 10001101

01101100 11000101


C programming

1. (LOW LEVEL Language) H/W Assembly

Assembly

MUL R1, D

STO R1, TEMP1

LOD R1 ,B

ADD R1,TEMP1


C programming

()

2. (High Level Language)

Pascal, Cobol, Fortran Basic

Pascal

program Test1;

var Name : String;

begin

writeln(Input your Name) Readln(name);

Writeln(Hello ,Name);

End.


C programming

()

3. (Middle Level language) C

2 C

H/W

C

C

#include (iostream.h)

main()

{

..

return 0

}


C programming

Hello Link

2

1.

Interpreter 1

Print Hello Link \n ;

print How are you?;

Interpreter


C programming

()

2.

Compiler

Hello Link

How are You

Print Hello Link \n ;

print How are you?;

Compiler


C programming

C

Test.c

#include (iostream.h)

main()

{

cout<<Hello World\n;

}

Binary File

.exe

test.exe

Object File

.obj

test.obj

Linker

C Compiler

C


C programming

C

  • H/W


C programming

C

2

1

Main()

Function

2


C programming

C

#include (iostream.h)

main()

{

cout<<C++;

return 0

}

Head

Body


C programming

Main() 2

1. (Preprocessor Directive)

2. (Declaration)

1

#include (stdio.h)

int x =4;

main()

{

cout<<C++;

return

}

2

main { }


Preprocessor directive

Preprocessor directive

C C

Preprocessor

Preprocessor # ;


Preprocessor directive1

#Include#Define#Error#if#Endfi

#Elid#Else#ifdef#ifndef#undef

#Line#Pragma

Preprocessor directive ()

Preprocessor Directive


C programming

C

  • C

  • ;


C programming

C

  • (Integer)

  • (Float)

  • (Octal)

  • (Hexadecimal)

  • (Character)

  • (String)


C programming

(Variable) (RAM)

1 num

16 16 num C

16

=

x = 10;

m = x+y;

a = A;


C programming

#include <Stdio.h>

int a= 5;

int b= 10;

int c;

main()

{

c= a+b;

printf (sum = %d\n, c);

}


C programming

C

2

1. (Scalar)


C programming

Type variable;

type :

variable :

int num;

float y;

char c;

double salary;


C programming

()

Type variable = value;

long million = 1000000;

int oct = 0234;

int hex = 0x45;

float temp = 15.236;

double stat = 1.25e-02;

char ch =#;


C programming

()

Type variable-1, variable-2,... variable-n;

type :

variable-1... Variable-n :

int num1,num2,num3;

float point1, point2,point3 = 12.00;

char a,b = B, c,d =D;


C programming

  • A-Z a-z _

  • A-Z a-z 0-9 _

  • 2

  • (Reserved Word)

  • 32


Reserved word

(Reserved Word)

autobreakcasecharconst

continuedefaultdodoubleelse

ifintlongregisterreturn

shortsignedsizeofstaticstruct

switchtypedefunionunsignedvoid

volatilewhile


C programming

class_room

hi-tech

9number

_hello123

age#

right!

last name


C programming

char[n] variable;

n : (Char) 10 11 C \0

Variable :

char[10] name; char[ ] color;


C programming

cout

(<<)

cout

cout << ;

cout<<Whats Your Name?<<endl;

cout<<Your Age is: <<age<<endl;

endl (end line)

\n


C programming

Comment

  • Comment Source code compiler comment

  • Comment 2

  • Comment //

  • Comment /* */

  • // Writen program by A.Prayoon


C programming

1

#include <iostream.h>

main()

{ int n;

n = 66;

cout << n << endl;

return 0;

}

2

#include <iostream.h>

// Test cout Command

main()

{

cout<<Sriwattana Institute of International<<endl;

return 0;

}


C programming

3

#include <iostream.h>

// Test cout Command

main()

{ int m,n,sum;

m = 10;

n = 20;

sum = 0;

cout<<Amount of M = <<m<<endl;

cout<<Amount of N = <<n<<endl;

sum = m + n;

cout<<Sum of M + N = <<sum<<endl;

return 0;

}


C programming

4( cout )

#include <iostream.h>

main()

{

cout<<******************************<<endl;

cout<< Number Name Surname <<endl;

cout<<471-1564 Urai Srimeed <<endl;

cout<<471-1662 Chanont Jitmun <<endl;

cout<<<<endl;

cout<<<<endl;

cout<<<<endl;

cout<<******************************<<endl;

return 0;

}


C programming

5( cout, cin-)

#include <iostream.h>

// Test cout, cin Command

main()

{ int x;

cout<<Enter Number : <<endl;

cin>> x;

cout<<Number is : << x <<endl;

return 0;

}

( Operators)


C programming

+ m+n

- m-n

- -n ()

* m*n

/ m/n

% m%n

6

#include <iostream.h>

// Test Arithmetic Operators;

main()

{ int m=38, n=5;

cout<<m<<+<<n<<=<<(m+n)<<endl;

cout<<m<<-<<n<<=<<(m-n)<<endl;

cout<< << - << = <<(-n)<<endl;

cout<<m<<*<<n<<=<<(m*n)<<endl;

cout<<m<</<<n<<=<<(m/n)<<endl;

cout<<m<<%<<n<<=<<(m%n)<<endl;

return 0;

}


C programming

/

++

--

++m m++

m = m+1

--m m--

m = m-1


C programming

7

#include <iostream.h>

// Test the increment and decrement operators

main()

{ int m=44, n=66;

cout<<m = <<m<<, n = <<n<<endl;

++m;

--n;

cout<<m = <<m<<, n = <<n<<endl;

m++;

n--;

cout<<m = <<m<<, n = <<n<<endl;

return 0;

}


C programming

/ ++m m++ m m

++m

m++

--m

m--


C programming

8

#include <iostream.h>

// Test the increment and decrement operators

main()

{ int m=66,n;

n = ++m;

cout<<m = <<m<<, n = <<n<<endl;

n = m++;

cout<<m = <<m<<, n = <<n<<endl;

cout<<m = <<m++<<endl;

cout<<m = <<m<<endl;

cout<< m = <<++m<<endl;

return 0;

}


C programming

(Character)

Character

ASCII

(American Standard Code for Information Interchange)

Monitor

ASCII

CPU


C programming

9

#include <iostream.h>

// Test output of type char;

main()

{ char c = A;

n = ++m;

cout<<c++ << << int(c) << endl;

cout<<c++ << << int(c) <<endl;

cout<<c++ << << int(c) <<endl;

return 0;

}

int(c) ASCII


C programming

\t \n

\t tab

\n endl

10

#include <iostream.h>

main()

{ cout<<\tFourscore andseven years ago our fathers \n

<<brought forth upon this continent a new nation: \n

<<concieved in liberty, and dedicated to the \n

<<proposition that all men are created equal. \n;

return 0;

}


C programming

11()

#include <iostream.h>

main()

{char first, last;

cout<<Enter your initials: \n;

cout<< \tFirst name initial: ;

cin>>first;

cout<<\tLast name initial: ;

cin>>last;

cout<<Hello; <<first<< . <<last<<.! \n;

return 0;

}


C programming

1.

200, 10.33745, A, Thailand

2.


C programming

( )

count++

True

Count<=n;

count=1

Cout<<Hello.;

False

13 for

#include <iostream.h>

main()

{ int i;

for (i=1; i< 3; i++)

cout<<Computer Program<<endl;

return 0;

}


C programming

14()

#include <iostream.h>

main()

{ int i, n;

cout<<Enter Number of Loop<<endl;

cin>>n;

for(i=1; i<=n; i++)

cout<<Good morning every body<<endl;

return 0;

}


C programming

16()

#include <iostream.h>

main()

{ int i, sum, n;

sum = 0;

cout<<Enter Number to Sum: ; cin>>n;

for (i=1; i<=n; i++)

sum=sum+ i ;

return 0;

}


C programming

  • 17( loop for 2 )

  • #include <iostream.h>

  • main()

  • { int i, j;

  • for (i=1; i<=3; i++)

  • for (j=1; j<=3; j++)

  • cout<<Hi! How are you? <<endl;

  • return 0;

  • }

  • for 1 for 3 for 3

  • for 1 for 2

    • m n

    • for (i=1; i<= m; i++) for (j=1; i<=n; j++)


C programming

18-1( for)

#include <iostream.h>

main()

{ int i, j;

for (i=1; i<=3; i++)

for (j=1; j<= i; j++)

cout<<Hi! How are you? <<endl;

return 0;

}

18-2( for)

#include <iostream.h>

main()

{ int i, j;

for (i=1; i<=3; i++)

for (j= i; j<= 3; j++)

cout<<Hi! How are you? <<endl;

return 0;

}


C programming

while

while

True

Count++ << limit

while

Cout<<Very Good;

False


C programming

20( 2)

#include <iostream.h>

main()

{ inti, n, sum;

i= 1; sum= 0;

cout<<Enter a Positive Integer: ;

cin>>n;

while (i<=n)

{ sum = sum + i * i;

i++;

}

cout<<The Sum of the First <<n<<endl;

cout<<Squares is: <<sum<<endl;

return 0;

}


C programming

21()

#include <iostream.h>

main()

{ intn, sum;

sum= 0;

cout<<Enter Number End by-999<<endl;

cin>>n;

while (n! = -999)

{sum = sum+n;

cin>>n;

}

cout<<Sum is <<sum<<endl;

return 0;

}


C programming

22()

#include <iostream.h>

main()

{float count, ave; int n, sum;

sum = 0; count = 0;

cout<<Enter Number(End by -999) : <<endl;

cin>>n;

while (n! = -999)

{count = count + 1;

sum = sum + n;

cin>>n;

}

ave = sum / count;

cout<<Sum is <<sum<<endl;

cout<<Average is <<ave<<endl;

return 0;

}


C programming

23( do..while)

#include <iostream.h>

main()

{ int n;

cout<<Enter Number (Cant over 10) : ;

cin>>n;

do

{ cout<<Value of n = <<n<<endl;

}


C programming

if

2 if.else

if.else

if ()

{ ;

;

}

else

{ ;

;

}


C programming

25()

#include <iostream.h>

main()

{ int score;

cout<<Please Input Your Score : ; cin>>score;

if (score>50)

cout<<You pass the Examination <<endl;

return 0;

}

26( 3 )

#include <iostream.h>

main()

{ int n1,n2,n3,max;

cout<<Enter three intrgers: ;

cin>>n1>>n2>>m3;

max=n1;

if (n2>max) max=n2;

if (n3>max) max=n3;

cout<<The maximum is <<max<<endl;

return 0;

}


C programming

27()

#include <iostream.h>

main()

{ int score;

cout<<Please Input Your Score: ;cin>>score;

if (score>50)

cout<<You pass the Examination <<endl;

else

cout<<Try Again ! <<endl;

return 0;

}

28( ifelse)

#include <iostream.h>

main()

{ int n1,n2,max;

cout<<Enter two integers: ;cin>>n1>>n2;

if (n1>n2) max=n1;

else max=n2;

cout<<Maximum is: <<max<<endl;

return 0;

}


C programming

2 if.else if.else

if.else if .else

if ()

;

else if ()

;

else

;


C programming

31( ))

#include <iostream.h>

main()

{ float count, ave; int n, sum, max, min;

sum=0;

cout<<Enter Number(End by-999): <<endl;

cin>> n;

while(n!=-999)

{sum=sum+n; count=count+1; max=n, min=n;

if (n>max) max=n;

ekse if (n<min) min=n; cin>>n;

}

ave = sum/count;

cout<<------------------------------------- <<endl;

cout<< Sum is : <<sum<< endl;

cout<< Average is : <<ave<<endl;

cout<< Maximum is : <<max<<endl;

cout<< Minimum is : <<min<<endl;

cout<<------------------------------------<<endl;

return 0;

}


C programming

switch

switch()

{ case value1 :

;

break;

case value2 :

;

break;

default:

;

}

switch case case case case default

break switch switch


C programming

32( switch.case)

#include <iostream.h>

main()

{ int n;

cout<<Enter Number : ; cin>>n;

switch(n)

{ case 1:

cout<<One<<endl;

break;

case 2:

cout<<Two<<endl;

break;

case 3:

cout<<Three<<endl;

break;

default:

cout<<No Value<<endl;

}

return 0;

}


C programming

33( switch.case )

#include <iostream.h>

main()

{ char n;

cout<<Enter the First Character of Program P/C/B : ; cin>>n;

switch(n)

{ case P:

cout<<Turbo Pascal<<endl; break;

case C:

cout<<Visual C++<<endl; break;

case B:

cout<<Visual Basic<<endl; break;

default:

cout<<You dont Select Program<<endl;

}

return 0;

}


  • Login