Presentation is loading. Please wait.

Presentation is loading. Please wait.

Daprogramebis safuZvlebi leqcia #3 2009-2010 sasw.w. I semestri Tsu asoc. prof. naTela arCvaZe Tsu asoc. prof. naTela arCvaZe Tsu, zusti da sabunebismetyvelo.

Similar presentations


Presentation on theme: "Daprogramebis safuZvlebi leqcia #3 2009-2010 sasw.w. I semestri Tsu asoc. prof. naTela arCvaZe Tsu asoc. prof. naTela arCvaZe Tsu, zusti da sabunebismetyvelo."— Presentation transcript:

1 daprogramebis safuZvlebi leqcia # sasw.w. I semestri Tsu asoc. prof. naTela arCvaZe Tsu asoc. prof. naTela arCvaZe Tsu, zusti da sabunebismetyvelo mecnierebaTa fakulteti, kompiuterul mecnierebaTa mimarTuleba

2 wina leqciaze ZiriTadi ganacxadebi da gamosaxulebebi int cvladi; /* komentari */ float cvladi; /* komentari */ char cvladi; /* komentari */ miniWebis Setyobineba beWdvis Setyobineba

3 Tema: marTvis Setyobinebebi ganStoebadi: pirobiTi, amorCevadi if Setyobineba if-else Setyobineba ganmeorebiTi, ciklis (looping): while Setyobineba break Setyobineba continue Setyobineba

4 if (piroba) Setyobineba; Tu studentis Sefaseba 51-ze metia an toli davbeWdoT sagani Cabarebulia. if (grade >= 51) printf("Passed course\n "); int grade; grade=…

5 , >=, ==, != && (and) ||(or) !=(no) grade>=51 daibeWdos sagani Cabarebulia diax ara

6 if-else Setyobineba if ( piroba ) Setyobineba1; else Setyobineba2; Tu Sefaseba 51-ze metia an toli davbeWdoT Tqven CaabareT sagani winaaRmdeg SemTxvevaSi davbeWdoT Tqven dagakldaT 51- grade qula

7 if (grade >= 51) printf("You passed course \n "); else printf("You need %d more points\n", 51- grade); grade>=51 daibeWdos Tqven CaabareT sagani diaxara daibeWdos Tqven dagakldaT 51-grade qula

8 #programis fragmentiSedegi 1 if(5>3)printf("yes"); yes 2 if(3>5) printf("no"); 3 int x=5;if(x>0) printf("%d is positive\n,x); 5 is positive 4 int y=-4; if(y<0) printf("%d is negative\n,y); -4 is negative 5 if(1)printf("yes");else printf("no"); yes 6 if(0)printf("yes");else printf("no"); no 7 int x=8; if(x>0) printf("yes"); else printf("no"); yes 8 int x=-8; if(x>0) printf("yes"); else printf("no"); no 9 int z=7; if(z>0)printf("%d is >0\n",z); else printf("%d is <0\n",z); 7 is >0

9 Cadgmuli if Setyobineba if (number > 0) /* pirveli if Setyobineba */ if ( number % 2 == 0) /* meore if Setyobineba */ printf("Number positive and even\n"); else printf("Number positive and odd\n");

10 #programis fragmentiSedegi 1 if(5>=0) if(3>2)printf("yes"); else printf("no"); yes 2 if(5>=0) if(2>3)printf("yes"); else printf("no"); no 3 if(5 3)printf("yes"); else printf("no"); 4 if(5 3)printf("yes"); else printf("no"); else printf("this"); this

11 #programis fragmentiSedegi 1 if(5>3 && 1)printf("yes\n"); else printf("no\n"); yes 2 int x=3; if(x==3 && 5<2)printf("yes\n"); else printf("no\n"); no 3 int y=5; if(0 && y>=0)printf("yes\n"); else printf("no\n"); no 4 if(2 3)printf("yes\n"); else printf("no\n"); yes 5 int k=0; if(5>2 || k)printf("yes\n"); else printf("no\n"); yes

12 pirobiTi operacia (piroba) ? gamosax 1: gamosax 2; max = (x > y) ? x : y ; max = x > y ? x : y ; if(x>y) max=x;else max=y; Abs = (x >= 0 )? x : -x ; Abs = x >= 0 ? x : -x ; if(x>=0)Abs=x;else Abs=-x;

13 rogor ar unda gamoviyenoT strcmp /* SevamowmoT string1 == string2 */ if (strcmp(string1, string2) == 0) printf("Strings equal\n"); else printf("Strings not equal\n"); ar SeiZleba ase Semokleba: if (strcmp(string1, string2)) printf("......");

14 ganmeorebis (looping) Setyobineba igive cikli while ( piroba ) Setyobineba ; piroba Sesasrulebeli Setyobinebebi diax ara

15 ipoveT 7 –idan 103 –mde 5-is jeradi ricxvebis jamis meoTxedi. int main() { int a=7; /* mTeli ricxvi, dawyebuli 7-dan */ int s=0; /* 5-is jeradi ricxvebis jami */ /* ricxvebisTvis 7-dan 103-is CaTvliT bijiT 1 */ while (a++<=108) //while(a<=108){ if(a%5==0) s+=a; // if(a%5==0) s=s+a; a=a++1;} /* Tu ricxvi 5-is jeradia davamatoT igi jams da TviTon ricxvi a gavzardo 1-iT */ printf("s=%0.2f\n", s/4.0); / * jamis meoTxedi */ system("pause"); return 0; }

16 break Setyobineba while ( piroba1 ) { operatori1 ; if ( piroba2 ) break; }... gagrZeleba...

17 continue Setyobineba while (1) Setyobineba ; while ( piroba1 ) { operatori1 ; if ( piroba2 ) continue; operatori2; }... gagrZeleba...

18 failSi Cawera #include int main() { char a, b, c; freopen( "data.txt", "r", stdin); scanf("%c%c%c", &a, &b, &c); freopen( "output.txt", "w", stdout); printf("%c %c %c", c, b, a); return 0;}

19 kursis kategoriebi: kompiuteruli mecnierebebi kursi: daprogramebis safuZvlebi Semodgoma :


Download ppt "Daprogramebis safuZvlebi leqcia #3 2009-2010 sasw.w. I semestri Tsu asoc. prof. naTela arCvaZe Tsu asoc. prof. naTela arCvaZe Tsu, zusti da sabunebismetyvelo."

Similar presentations


Ads by Google