فصل سوم. 2 Phases of C++ Programs: 1.Edit 2.Preprocess 3.Compile 4.Link 5.Load 6.Execute...
-
Upload
felicia-fitzgerald -
Category
Documents
-
view
215 -
download
2
Transcript of فصل سوم. 2 Phases of C++ Programs: 1.Edit 2.Preprocess 3.Compile 4.Link 5.Load 6.Execute...
![Page 1: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/1.jpg)
Cمفاهیم اولیه زبان فصل سوم
![Page 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/2.jpg)
2
1.14 BASICS OF A TYPICAL C PROGRAM DEVELOPMENT ENVIRONMENT
• Phases of C++ Programs:1. Edit2. Preprocess3. Compile4. Link5. Load6. Execute
Program is created in
the editor and stored
on disk.Preprocessor
programprocesses the
code.
Loader puts program in
memory.
CPUtakes eachinstruction and
executes it, possibly storing
new data values as the program
executes.
Compiler creates object code and
storesit on disk.Linker links the
objectcode with the
librariesLoader
Primary Memory
Compiler
Editor
Preprocessor
Linker
Primary Memory
.
.
.
.
.
.
.
.
.
.
.
.
Disk
Disk
Disk
CPU
Disk
Disk
![Page 3: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/3.jpg)
![Page 4: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/4.jpg)
c:کلمات رزرو شده زبان
![Page 5: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/5.jpg)
مثال ساده:
![Page 6: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/6.jpg)
![Page 7: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/7.jpg)
C STANDARD HEADER FILES YOU MAY WANT TO USE
استاندارد توابع :مهمترین 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.
![Page 8: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/8.jpg)
: خروجی و ورودی دستورات
![Page 9: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/9.jpg)
![Page 10: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/10.jpg)
![Page 11: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/11.jpg)
# include < stdio.h >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);}
مثال: برنامه ای بنویسید تا شعاع دایره را از ورودی
بخواند و محیط و مساحت آنرا حساب کند و نمایش دهد.
![Page 12: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/12.jpg)
![Page 13: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/13.jpg)
![Page 14: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/14.jpg)
//9 simple program# include < conio.h >#include <stdio.h>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,x>>4);getch();}
![Page 15: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/15.jpg)
![Page 16: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/16.jpg)
![Page 17: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/17.jpg)
; از آدرس float a[5]تمرین :فرض کنید محل ذخیره آرایه 0x0100 شروع می شود.تعیین کنید تا چه آدرسی به آرایه
است)AVR ATMEGA 16فوق اختصاص می یابد.(میکرو
![Page 18: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/18.jpg)
آرایه های دو بعدی:
یعنی آرایه ای از آرایه های یک بعدی
مثال:
فرض کنید دو آرایه یک بعدی بشکل زیر داریم:
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)=1 C(0,1)=2
C(0,2)=3
C(1.0)=4 C(1,1)=5
C(1,2)=6
![Page 19: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/19.jpg)
روش تعریف آرایه های دو بعدی:
[ اسم آرایه ] تعداد ستون ][ تعداد سطر نوع متغیرها
![Page 20: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/20.jpg)
![Page 21: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/21.jpg)
Main)(
{
Int i=0;
HERE:
i;++
If (i<10)
Goto HERE;
Printf(“THE MAX value of i is:%d “,i);
Getch;)(
}
![Page 22: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/22.jpg)
مثال:
![Page 23: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/23.jpg)
![Page 24: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/24.jpg)
![Page 25: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/25.jpg)
![Page 26: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/26.jpg)
![Page 27: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/27.jpg)
![Page 28: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/28.jpg)
![Page 29: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/29.jpg)
![Page 30: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/30.jpg)
را عددی که بنویسید تابعیتوان و بگیرد ورودی 3از
نماید چاب و حساب انرا
![Page 31: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/31.jpg)
تابعی: 2مثال عدد دو که بنویسید
و بگیرد ورودی از رارا آنها بزرگترین
نماید چاب و تعیین
![Page 32: فصل سوم. 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.](https://reader035.fdocuments.us/reader035/viewer/2022062713/56649f4f5503460f94c706ac/html5/thumbnails/32.jpg)