Sunum yükleniyor. Lütfen bekleyiniz

Sunum yükleniyor. Lütfen bekleyiniz

C. Dennis Ritchie 9 Eylül 1941 - ö. 12 Ekim 2011.

Benzer bir sunumlar


... konulu sunumlar: "C. Dennis Ritchie 9 Eylül 1941 - ö. 12 Ekim 2011."— Sunum transkripti:

1 C

2 Dennis Ritchie 9 Eylül 1941 - ö. 12 Ekim 2011

3 Derleyiciler - Compiler Basitçe bir dilde yazılmış olan kodu (kaynak kodu yada source code) istenilen başka bir kod haline dönüştüren programdır. Genelde üretilen bu kod ortama göre çalıştırılabilir kod (executable code) olarak üretilmektedir. Ancak bir derleyicinin daha doğru tanımı bir dildeki kodu başka dile çeviren program olarak yapılabilir. Örneğin C dilinde yazılan bir programı PASCAL diline çeviren programlara derleyici adı verilebilir. Derleyicinin diğer bir tanımı ise daha üst seviye bir dilden daha alt seviyeli bir dile tercüme olarak kabul edilebilir. Buna göre örneğin C dilinden Assembly veya makine dili gibi daha alt dillere tercüme ile derleyici kavramı daha da sınırlandırılmış olarak kabul edilebilir. Derleyiciler günümüzde daha çok bir dilde yazılmış koddan, işletim sistemi ve donanım bağımlı kodların üretilmesinde kulllanılmaktadırlar. Bu üretim sırasında ya doğrudan işletim sisteminin anlayacağı ve çalıştıracağı kodları üretirler ya da işletim sisteminde bulunan veya yine dil bağımlı olarak çalışan bağlayıcı (linker) programların anlayacağı ara kodları üretirler. bağlayıcı (linker) Derleyiciler bu kod üretmesi sırasında, üretilen kodun en verimli şekilde üretilmesi için kod iyileştirmesi (optimisation) da yapmaktadırlar. Yani hedef dildeki çalışma süresi ve hafıza ihtiyacı en az olan kodu üretmek bir derleyicinin daha başarılı olma kriterlerinden birisidir.hafıza Aynı zamanda kaynak kodda (source code) bulunan hataların yakalanması bu hataların programcıya bildirilmesi de derleyicilerin diğer görevlerinden birisidir.

4 Akış şeması

5

6

7

8 Organizasyon

9 // Documentation Section // This program calculates the area of square shaped rooms // Author: x person // Date: 6/28/2013 // // 1. Pre-processor Directives Section #include // Diamond braces for sys lib: Standard I/O #include "uart.h" // Quotes for user lib: UART lib // 2. Global Declarations section // 3. Subroutines Section // MAIN: Mandatory routine for a C program to be executable int main(void) { UART_Init(); // call subroutine to initialize the uart printf("This program calculates areas of square-shaped rooms\n"); }

10 Veri Türleri int main(void) { unsigned long side; // room wall meters unsigned long area; // size squared meters UART_Init(); // call subroutine to initialize the uart side = 3; area = side*side; printf("\nArea of the room with side of %ld m is %ld sqr m\n",side,area); }

11 Aritmetik İşlemler void main(void){ long x,y,z; // Three local variables x=1; y=2; // set the values of x and y z = x+4*y; // arithmetic operation x++; // same as x=x+1; y--; // same as y=y-1; x = y >2; // right shift same as x=y/4; y += 2; // same as y=y+2; }

12

13 Function Fonksiyonlar alt programdır. Bir fonksiyon geriye değer gönderebilir veya gönderemez. void türünden bir fonksiyon geriye değer döndürmez. void türünden bir alt program sadece bir işlevi yapar ve belki de bir işe yaramaz veya yarar.

14 void hi_de( ) { printf(‘‘Hello Sınıf’’); } Fonksiyon void rakamisoyle (int x) { printf(‘‘ Yazdığın rakam %d’dir’’, x ); } void toplabakalim (int x,double y) { long k; k=x+y; } Bir işe yaramadı.

15 Geriye değer döndüren fonksiyonlar long toplamayap(int x, int y) { sonux=x+y; return sonuc; } void main { long k; k=toplamayap(2,3); }

16 unsigned long Calc_Area(unsigned long s); int main(void) { unsigned long side; // room wall meters unsigned long area; // size squared meters UART_Init(); // call subroutine to initialize the uart printf("This program calculates areas of square-shaped rooms\n"); side = 3; area = Calc_Area(side); printf("\nArea of the room with side of %ld m is %ld sqr m\n",side,area); side = side+2; area = Calc_Area(side); printf("\nArea of the room with side of %ld m is %ld sqr m\n",side,area); } // Calculates area // Input: side of a room (unsigned long) in meters // Output: area of the room (unsigned long) in square meters unsigned long Calc_Area(unsigned long s) { unsigned long result; result = s*s; return(result); }

17 // Calculates area // Input: side of a room (unsigned long) in meters // Output: area of the room (unsigned long) in square meters unsigned long Calc_Area(unsigned long s) { unsigned long result; result = s*s; return(result); } int main(void) { unsigned long side; // room wall meters unsigned long area; // size squared meters UART_Init(); // call subroutine to initialize the uart printf("This program calculates areas of square-shaped rooms\n"); side = 3; area = Calc_Area(side); printf("\nArea of the room with side of %ld m is %ld sqr m\n",side,area); side = side+2; area = Calc_Area(side); printf("\nArea of the room with side of %ld m is %ld sqr m\n",side,area); }

18 Conditional unsigned long error; // Calculates area // Input: side of a room (unsigned long) // Output: area of the room (unsigned long) // Notes:... unsigned long Calc_Area(unsigned long s) { unsigned long result; if(s <= 25){ result = s*s; } else { result = 0; // mistake error = error +1; } return(result); } int main(void) { unsigned long side; // room wall meters unsigned long area; // size squared meters UART_Init(); // call subroutine to initialize the uart printf("This program calculates areas of square-shaped rooms\n"); side = 1; while(side < 50){ area = Calc_Area(side); printf("\nArea of the room with side of %ld m is %ld sqr m\n",side,area); side = side+1; }

19 Loop for(part1;part2;part3){body;} int main(void) { unsigned long side; // room wall meters unsigned long area; // size squared meters UART_Init(); // call subroutine to initialize the uart printf("This program calculates areas of square-shaped rooms\n"); for(side = 1; side < 50; side = side+1){ area = Calc_Area(side); printf("\nArea of the room with side of %ld m is %ld sqr m\n",side,area); }


"C. Dennis Ritchie 9 Eylül 1941 - ö. 12 Ekim 2011." indir ppt

Benzer bir sunumlar


Google Reklamları