1 / 15

daprogramebis safuZvlebi leqcia #2

daprogramebis safuZvlebi leqcia #2. 2009-2010 sasw.w. I semestri Tsu asoc. prof. naTela arCvaZe Tsu, zusti da sabunebismetyvelo mecnierebaTa fakulteti, kompiuterul mecnierebaTa mimarTuleba. 1. wina leqciaze.

rangle
Download Presentation

daprogramebis safuZvlebi leqcia #2

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 #2 2009-2010 sasw.w. I semestri Tsu asoc. prof. naTela arCvaZe Tsu, zusti da sabunebismetyvelo mecnierebaTa fakulteti, kompiuterul mecnierebaTa mimarTuleba

  2. 1. wina leqciaze • Sesavali daprogramebis ena C-Si • stili programis daweris wesebi: • programa 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

  3. Tema:ZiriTadi ganacxadebi da gamosaxulebebi

  4. programis ZiriTadi struqtura /************************************* * . . . sawyisikomentarebi . . . * *************************************/ . . . ganacxadebi monacemebze . . . int main () { ... Sesrulebadi Setyobinebebi... return (0); }

  5. magaliTi hello.cpp. /********************************************* * 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); }

  6. gamosaxulebebi • martivi operatorebi: +, _, *, /, % (naSTi mT. gayofisas miR.) /* Sedegi ar aqvs */ int main() { ( 1 + 2 ) * 3; return (0); }

  7. cvladebis saxelebi • gamoiyeneba asoebi, cifrebi da qveda tires simbolo ( _) • saxeli ar SeiZleba cifriT iwyebodes • sworea: sashualo, Pi, studentebis_raodenoba, gio, Gio,GIO • arasworea: 2_cda, fasi$, studentebis raodenoba, int, for

  8. ganacxadi cvladebzemTeli ricxvebi tipi saxeli; /* komentari */ intsaxeli;/* komentari */ • 32 biti (4 baiti) - 2147483648(-231)-dan 2147483647(231-1)-mde • 16 bits (2 baits), -32768(-215)-dan 32767(215-1)-mde. • limits.h - mudmivebi, romelTa mniSvnelobebiaA sxvadasxva diapazonis sazRvrebi (mag.,INT_MAX, INT_MIN)

  9. miniWebis Setyobinebacvladi = gamosaxuleba;

  10. funqciaprintf printf ( formati, gamos1, gamos2, . . . ); #include <stdio.h> #include <stdlib.h> int term;/* termgamoiyeneba or gam. */ int main() { term = 3 * 5; printf ("gaormagebuli %d aris %d \n", term, 2 * term); printf ("gasammagebuli %d aris %d \n", term, 3 * term); system ("PAUSE"); return (0);}

  11. namdvili ricxvebi floatcvladi;/*komentari*/ • 1 + 2 = 3 • 1.0 + 2.0 = 3.0 • 19 / 10 = 1 • 19.0 / 10.0= 1.9

  12. magaliTi int i; /* mTeli tipis cvladi saxeliT i */ float x;/* mcocavwertiliani cvladi saxeliTx */ main() { x = 1.0/2.0; /* mianiWebs cvladx-smniS. 0.5 */ i= 1/3;/* mianiWebs cvlad i-s mniS. 0 */ x = (1/2)+(1/2); /* mianiWebs cvlads x -s mniSv. 0 */ x = 3.0/2.0; /* mianiWebs cvlad x-smniS. 1.5 */ i = x; /* mianiWebs cvlad i-smniS. 1 */ return (0); }

  13. simboloebi char cvladi; /* komentari */ mmarTveli simboloebi: \b \f \n \r \t \‘ \“ \a

  14. magaliTi #include <stdio.h> #include <stdlib.h> char char1; /* pirveli simbolo */ char char2; /* meore simbolo */ char char3; /* mesame simbolo */ int main() { char1='A'; char2='B'; char3='C'; printf("%c%c%c gardaiqmneba %c%c%c-ad\n", char1,char2,char3,char3,char2,char1); system (“PAUSE”); return(0); } pasuxi: ABC gardaiqmneba CBA-ad.

More Related