Presentation is loading. Please wait.

Presentation is loading. Please wait.

فصل سوم. 2 Phases of C++ Programs: 1.Edit 2.Preprocess 3.Compile 4.Link 5.Load 6.Execute Program is created in the editor and stored on disk. Preprocessor.

Similar presentations


Presentation on theme: "فصل سوم. 2 Phases of C++ Programs: 1.Edit 2.Preprocess 3.Compile 4.Link 5.Load 6.Execute Program is created in the editor and stored on disk. Preprocessor."— Presentation transcript:

1 فصل سوم

2 2 Phases of C++ Programs: 1.Edit 2.Preprocess 3.Compile 4.Link 5.Load 6.Execute Program is created in the editor and stored on disk. Preprocessor program processes the code. Loader puts program in memory. CPUtakes each instruction and executes it, possibly storing new data values as the program executes. Compiler creates object code and stores it on disk. Linker links the object code with the libraries Loader Primary Memory Compiler Editor Preprocess or Linker Primary Memory........................ Disk CPU Disk

3

4 کلمات رزرو شده زبان :c

5 مثال ساده :

6

7  مهمترین توابع استاندارد:  stdio.h – file and console (also a file) IO: printf, open, close, read, write, scanf, etc.  string.h - string and byte manipulation: strlen, strcpy, strcat, memcpy, memset, etc.  errno.h – defines errno used for reporting system errors  math.h – math functions: sin, exp, floor, sqrt, etc.  time.h – time related facility: asctime, clock, time_t, etc.

8 دستورات ورودی و خروجی :

9

10

11 # include void main () { const float pi = 3.14 ; float r,p,s; printf (" please enter reduce : \n ") ; scanf("%f",&r); p = 2*pi * r ; s = pi * r *r ; printf (" The S = %f, The P = % f ", s,p) ; while(1); } مثال : برنامه ای بنویسید تا شعاع دایره را از ورودی بخواند و محیط و مساحت آنرا حساب کند و نمایش دهد.

12

13

14 //9 simple program # include void main() { int a=21,b=10,c; c=a%b; printf("a=%d,b=%d c=%d \n",a,b,c); int x=0xf0,y=0x0f; printf(" %x,%x, %x,%x ",x&y,x|y,y >4); getch(); }

15

16

17 تمرین : فرض کنید محل ذخیره آرایه float a[5]; از آدرس 0x0100 شروع می شود. تعیین کنید تا چه آدرسی به آرایه فوق اختصاص می یابد.( میکرو AVR ATMEGA 16 است )

18 آرایه های دو بعدی : یعنی آرایه ای از آرایه های یک بعدی مثال : فرض کنید دو آرایه یک بعدی بشکل زیر داریم : Int a[3]={1,2,3} int b[3]={4,5,6} حال می خواهیم انها را بصورت یک آرایه دو بعدی نمایش دهیم : int c[2][3]={{1,2,3},{4,5,6}} C(0,0)=1C(0,1)=2C(0,2)=3 C(1.0)=4C(1,1)=5C(1,2)=6

19 روش تعریف آرایه های دو بعدی : ] تعداد ستون ][ تعداد سطر [ اسم آرایه نوع متغیرها

20

21 Main() { Int i=0; HERE: i++; If (i<10) Goto HERE; Printf(“THE MAX value of i is:%d “,i); Getch(); }

22 مثال :

23

24

25

26

27

28

29

30 تابعی بنویسید که عددی را از ورودی بگیرد و توان 3 انرا حساب و چاب نماید

31 مثال 2 : تابعی بنویسید که دو عدد را از ورودی بگیرد و بزرگترین آنها را تعیین و چاب نماید

32


Download ppt "فصل سوم. 2 Phases of C++ Programs: 1.Edit 2.Preprocess 3.Compile 4.Link 5.Load 6.Execute Program is created in the editor and stored on disk. Preprocessor."

Similar presentations


Ads by Google