1 / 18

daprogramebis safuZvlebi leqcia #1

daprogramebis safuZvlebi leqcia #1. 2009-2010 sasw.w. I semestri Tsu, zusti da sabunebismetyvelo mecnierebaTa fakulteti, kompiuterul mecnierebaTa mimarTuleba. 1. ras warmoadgens C. ra aris programireba rogor muSaobs C rogor SeviswavloT C programebi-amocanis dasmidan Sesrulebamde

yadid
Download Presentation

daprogramebis safuZvlebi leqcia #1

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. daprogramebis safuZvlebileqcia #1 2009-2010 sasw.w. I semestri Tsu, zusti da sabunebismetyvelo mecnierebaTa fakulteti, kompiuterul mecnierebaTa mimarTuleba

  2. 1. ras warmoadgens C • ra aris programireba • rogor muSaobs C • rogor SeviswavloT C • programebi-amocanis dasmidan Sesrulebamde • programis Seqmna integrirebul garemoSi

  3. ra aris programireba C enis ZiriTadi funqciaa programistsa da kompiuters Soris urTierTobis damyareba manqanuri enis instruqcia - 0 da 1 asembleri (instruqciebis krebuli) Targmna programa (assembly language) MOV A,47 1 ADD A,B HALT . . . • igive programamanqanur enaze • 010 1111 • 0011 0111 • 0111 0110 • . . .

  4. rogor muSaobs C C-is popularobis mizezebi: moqniloba gadatanadoba kompiuteruli programa monacemebi (data) instruqciebi (instructions)

  5. monacemebi • mexsierebis erTeuli-baiti (8 biti) • monacemi-baitebis mimdevroba • aRiweros monacemi int total/* angariSebis jami */ int balance[100] /* balansi 100 angariSisTvis */ struct rectangle { int width; /* marTkuTxedis sigane piqselebSi */ int height; /* marTkuTxedis simaRle piqselebSi */ color_type color /* marTkuTxedis feri */ fill-type fill; /* Sevsebis wesi */ };

  6. instruqciebi • miniWebis Setyobineba (assignment statement) area=(base * height)/2.0; /* samkuTxedis farTobis gamoTvla */ • marTvis Setyobinebebi: pirobiTi (if, switch) ganmeorebiTi (while, for) • funqciebi-Setyobinebebis jgufi • funqciaTa jgufi–sawyisi faili (sourse file)

  7. maRali donis kodi kompileri instruqciebis krebulis ena asembleri saboloo kodi amkinZavi programa biblioTeka Sesrulebadi programa rogor SeviswavloT Cprogramebi-amocanis dasmidan Sesrulebamde

  8. programis Seqmna integrirebul garemoSi integrebul garemo (IDE) Seicavs teqstur redaqtors, sxvadasxva menius, marTvis Rilakebs da a.S. Dev-C++

  9. 2. stili • ra aris stili • komentarebi • programis kodis wera: gavrcelebuli midgomebi • stili Tu kulti? • kodis formatireba wanacvlebis saSualebiT • sicxade da simartive

  10. komentarebi /************************************************ * hello -- program to print out "Hello World". * * Not an especially earth-shattering program * * Author: Steve Oualline. * * * * Purpose: Demonstration of a simple program. * * * Usage: * * Runs the program and the message appears. * *************************************************/ #include <stdio.h> #include <stdlib.h> int main() { /* Tell the world hello */ printf("Hello World\n"); system (“PAUSE”); return (0); }

  11. /******************************** ********************************* * gafrTxileba:es aris gamafrTxilebeli * * gzavnilis magaliTi, romelic * * programistis yuradRebas miiqcevs * ************************************ ***********************************/

  12. /*----------> sxva, naklebad mniSvnelovani Setyobineba <--------*/ /*>>>>>>>>>>>> mTavari seqciis saTauri <<<<<<<<<<<<<<< */ /******************************************************** * Cven viyenebT CarCoSi Casmul komentarebs programis * * seqciis dasawyisis aRniSvnisaTvis * ********************************************************/ /*------------------------------------------------------*\ * es aris CarCos daxatvis sxva xerxi * \*------------------------------------------------------ */ /* * es aris seqciis dasawyisi * ^^^^ ^^ ^^^ ^^^^^^^^^ ^^ ^ ^^^^^^^ * Semdeg paragrafSi Cven avxsniT, ras warmoadgens seqcia * * da rogor muSaobs igi */ /* * saSualo donis komentari, romelic exeba programis * * momdevno ramodenime striqons. Tumca Cven ar gvaqvs msxvili Srifti, * Cven mainc SegviZlia **gamovyoT** sityvebi */ /* martivi komentari, romlebic exeba programis momdevno striqons*/

  13. kodis formatireba wanacvlebis saSualebiT /************************************************** * programa gamoicnobs udris Tu ara ricxvi 5-s * * Author: Irina * *************************************************/ #include <stdio.h>/* standartuli Setana-gamotanis biblioTekis CarTva */ #include <stdlib.h> /* standartuli funqciebis biblioTekis CarTva */ int main() /* mTavari funqcia */ { int a; /* ganacxadi mTel ricxvze */ a=5;/* a-sTvis 5-is miniWeba */ /* amorCeva: ricxvis 5-Tan Sedareba */ if( a == 5 )/* Tu a udris 5-s, maSin */ { printf("Hello,\n"); /*ekranze gamoCndeba gzavnili Hello da*/ printf("a = 5\n"); /*Semdeg striqonSi gzavnili a = 5 */ } else /* Tu a ar udris 5-s, maSin */ { printf("I'm Program\n"); /*ekranze daibeWdeba I'm Program da */ printf("I know, a isn’t 5\n"); /*Semdeg striqonSi: I know, a isn’t 5*/ } system (“PAUSE”); /* ekranis gasaCereblad */ return 0; }

  14. arsebobs wanacvlebis ori ZiriTadi stili. pirveli _ mokle formaa: int main() { int a; a=5; if( a == 5 ) { printf("Hello,\n"); printf("a = 5"); } else { printf("I'm Program\n"); printf("I know, a isn’t 5"); } system (“PAUSE”); return 0; }

  15. meore stili figurul frCxilebs calke striqonebze svams: int main() { int a; a=5; if( a == 5 ) { printf("Hello,\n"); printf("a = 5"); } else { printf("I'm Program\n"); printf("I know, a isn’t 5"); } system (“PAUSE”); return 0; }

  16. sicxade da simartive /* arcTu saukeTeso programa */ temp = x1; x1 = x2; x2 = temp; temp = y1; y1 = y2; y2 = temp;

  17. /* * adgili gavucvaloT(swap) AdaB-s */ /* Xkoordinatebis gacvla*/ temp = x1; x1 = x2; x2 = temp; /* Ykoordinatebis gacvla*/ temp = y1; y1 = y2; y2 = temp;

  18. programis daweris wesebi • ecadeT, Tqvens programas ar hqondes rTuli logika. dayaviT calkeul procedurebad da SeamcireT sirTulis xarisxi • grZel instruqciebs Tavi aarideT-programa ase ufro advili aRsaqmeli iqneba • ecadeT Tqveni programa iyos rac SeiZleba martivi da naTeli

More Related