Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

2 wina leqciaze: ricxvebis wakiTxva scanf( formati, & cvl1, & cvl2...); informaciis Setana-gamotanis gadamisamarTeba. funqcia freopen freopen ( misam., reJimi, nakadis_sax ); freopen ("c:\monacemebi\data.txt", "r", stdin); freopen ("c:\shedegi.txt", "w", stdout); 2

3 Tema: ricxvebis tipebi mTeli ricxvebis tipebi long int cvladis-saxeli ; short int cvladis-saxeli ; sizeof(short) sizeof( int) sizeof(long) signed long int result; igivea, rac long result; 3

4 specifikatorebi printf() da scanf() funqciebSi specifikatorebigamoyenebebi %hd(signed) short int %d(signed) int %ld(signed) long int %huunsigned short int %uunsigned int %luunsigned long int 4

5 #include int main(){ int x = INT_MIN, y = INT_MAX; unsigned int ux = UINT_MAX; long int lx = LONG_MIN, ly = LONG_MAX; unsigned long int lu = ULONG_MAX; short int sx = SHRT_MIN, sy = SHRT_MAX; unsigned short int su = USHRT_MAX; printf("int ikavebs %d baits\n", sizeof(int)); printf("misi diapazonia %d : %d\n", x,y); printf("unsigned int-is diapazonia 0 : %u\n", ux); printf("long int ikavebs %d baits\n", sizeof(long)); printf("misi diapazonia %ld : %ld\n", lx,ly); printf("unsigned long-is diapazonia 0 : %lu\n", lu); printf("short int ikavebs %d baits\n", sizeof(short)); printf("misi diapazonia %hd : %hd\n", sx,sy); printf("unsigned short int-is diapazonia 0 : %hu\n", su); return 0;} 5

6 programis Sedegia: int ikavebs 4 baits misi diapazonia -2147483648 : 2147483647 unsigned int- is diapazonia 0 : 4294967295 long int ikavebs 4 baits misi diapazonia -2147483648 : 2147483647 unsigned long- is diapazonia 0 : 4294967295 short int ikavebs 2 baits misi diapazonia -32768 : 32767 unsigned short int- is diapazonia 0 : 65535 6

7 tipi char diapazoni (-128)- dan 127- mde. unsigned char diapazoni 0– dan 255– mde. ASCII (American Standard Code for Information Interchange) scanf("%c", &symbol); - araa rekomendirebuli - getchar(); putchar(); char ch; ch = getchar(); - simbolos wakiTxva putchar( simbolo ); - ekranze dabeWdva mag. char ch ='Z'; putchar(ch); - is funqcia getch() msgavsia system("PAUSE") - is 7

8 magaliTi: #include int main() { char p; printf("Enter a symbol : "); p=getchar(); /* simbolos wakiTxva */ printf("Symbol is : "); putchar(p); /* simbolos beWdva */ getch(); /* ekranis gaCereba */ return 0; } 8

9 namdvili ricxvebis tipebi float, double, long double float f; /* namdvili ricxvi */ double d; /* ormagi sizustis */ long double x; /* gazrdili sizustis */ int main() { printf("float ikavebs %d baits\n", sizeof(f) ); printf("double ikavebs %d baits\n", sizeof(d) ); printf("long double - %d baits\n", sizeof(x) ); return 0; } programis Sesrulebis Sedegi: float ikavebs 4 baits double ikavebs 8 baits long double - 12 baits 9

10 specifikatorebi printf() da scanf() funqciebSi ganacxadebi mudmivebze const tipi cvladis_saxeli = mniSvneloba ; magaliTad, const float PI = 3.141592; specifikatorebigamoyenebebiSeniSvna %ffloatprintf -sa da scanf -isTvis %fdouble mxolod printf -isTvis %lfdouble mxolod scanf -isTvis %Lflong double yvela kompiuterisTvis ar gamoiyeneba 10

11 TeqvsmetobiTi da rvaobiTi mudmivebi ricxvi iwyeba 0x– iT - TeqvsmetobiTi ricxvi iwyeba 0– iT - rvaobiTi ricxvi int k = 020+0x20+20; //8- biTi, 16- biTi da 10- biTi ocebis jami printf("%d\n",k); // daibeWdeba 68 ( 16+32+20) 11

12 magaliTi: #include #include int main() { int x = 100; printf("dec=%d;octal=%o;hex=%x\n",x,x,x); printf("dec=%d;octal=%#o;hex=%#x\n",x,x,x); system("PAUSE"); return 0; } programis Serulebis Sedegi: dec = 100; octal = 144; hex = 64 dec = 100; octal = 0144; hex = 0x64 12

13 for ciklis operatori for ( inicializeba; piroba; koreqcia) Setyobineba; while ( pirobis Semowmeba ) { Setyobineba; koreqcia; } 13

14 magaliTi: SevkriboT 5 ricxvi ( while cikliT) #include int total; /* yvela ricxvis jami */ int current; /* damxmare cvladi */ int counter; /* ganmeorebaTa mTvleli */ int main(){ total=0; counter=0; while(counter<5){ printf("number? "); scanf("%d", ¤t); total+=current; ++counter; } printf("The grand total is %d\n", total); return (0); } 14

15 magaliTi: SevkriboT 5 ricxvi ( for cikliT ) #include int total; /* yvela ricxvis jami */ int current;/* damxmare cvladi */ int counter;/* ganmeorebaTa mTvleli */ int main(){ total=0; for (counter=0;counter<5;++counter){ printf("number? "); scanf("%d", ¤t); total+=current; } printf("The grand total is %d\n", total); return (0); } 15

16 16

17 konsultacia: yovel paraskevs 16 saaTze 805 auditoriaSi kursis kategoriebi: kompiuteruli mecnierebebi kursi: daprogramebis safuZvlebi- 2009 Semodgoma : http://moodle.science.tsu.ge/ 17


Download ppt "Daprogramebis safuZvlebi leqcia #5 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