g. surgulaZe, g. janeliZe, i. xuciSvili

g. surgulaZe, g. janeliZe, i. xuciSvili g. surgulaZe, g. janeliZe, i. xuciSvili

01.03.2013 Views

programis muSaobis Sedegia: 2 4 8 e.i. tipi short int ikavebs mexsierebaSi 2 baits, x+y gamosaxulebis tipia long da am tips gamoeyofa 4 baiti. saintereso Sedegi mogvca operatorma printf("\n%d", sizeof(x+z)); x+z gamosaxulebaSi mocemulia 2 gansxvavebuli tipis cvladis jami: x – long tipisaa, z – double tipis. programam daadgina mocemuli jamis tipi, rogorc double da dabeWda 8 (baiti). 1.5.1. tipebis gardaqmna ariTmetikul gamosaxulebaSi C-Si daSvebulia ariTmetikul gamosaxulebaSi sxvadasxva tipis cvladebis gamoyeneba. aseTi gamosaxulebis gamoTvlis dros sruldeba tipebis avtomaturi gardaqmna. moviyvanoT ramdenime wesi, romelic gamoiyeneba tipebis avtomaturi gardaqmnis (amboben – tipebis dayvanis) dros: 1. float tipis operandebi daiyvaneba double tipze; 2. Tu erTi operandi long double tipisaa, meorec daiyvaneba amave tipze; 3. Tu erTi operandis tipia double, meorec gardaiqmneba double tipad; 4. char da short tipis operandebi daiyvaneba int tipze; 5. yoveli unsigned char da unsigned short operandi daiyvaneba unsigned int tipze; 6. Tu erTi operandi unsigned long tipisaa, meore operandis tipic gaxdeba unsigned long; 7. Tu erTi operandis tipia long, meore operandis tipic gaxdeba long; 8. Tu erTi operandis tipia unsigned int, meore operandis tipic gaxdeba unsigned int. 33

wesebi gviCvenebs, rom gamosaxulebis gamoTvlisas operandebi daiyvaneba im operandis tipze, romelsac udidesi zoma aqvs. magaliTad, mocemulia aRwera: double f, s; unsigned char ch; unsigned long k; int i; unda gamoviTvaloT s=f*(i+ch/k); tipebis gardaqmnis Tanmimdevroba Semdegia: operandi ch daiyvaneba unsigned int tipze (wesi 5), Semdeg igive ch daiyvaneba unsigned long tipze, radganac ch/k operaciaSi k - unsigned long tipisaa (wesi 6), Semdeg i daiyvaneba unsigned long tipze, da mrgval frCxilebSi mocemuli gamosaxulebis Sedegi iqneba unsigned long tipis. es Sedegi daiyvaneba double tipze (wesi 3), da mTeli gamosaxulebis tipi iqneba double. 1.5.2. tipebis gardaqmna miniWebisas miniWebis dros Tu miniWebis operaciis marjvena da marcxena operandebis tipebi gansxvavdeba, moqmedebs tipebis gardaqmnis martivi wesi: miniWebis operaciis marjvena mxares mdebare mniSvnelobis tipi daiyvaneba im cvladis tipze, romelsac eniWeba mniSvneloba. magaliTad, programa #include main() { short x=19; char y=125; float z; z=x+y; printf("%d %d %d",sizeof(x), sizeof(y), sizeof(x+y)); printf("\n%d %f", sizeof(z), z); return 0; } daabrunebs Sedegs: 2 1 4 4 144.000000 pasuxidan Cans, rom x+y-is mniSvneloba gardaiqmna z-is tipze. 34

wesebi gviCvenebs, rom gamosaxulebis gamoTvlisas operandebi<br />

daiyvaneba im operandis tipze, romelsac udidesi zoma aqvs.<br />

magaliTad, mocemulia aRwera:<br />

double f, s; unsigned char ch; unsigned long k; int i;<br />

unda gamoviTvaloT<br />

s=f*(i+ch/k);<br />

tipebis gardaqmnis Tanmimdevroba Semdegia: operandi ch daiyvaneba<br />

unsigned int tipze (wesi 5), Semdeg igive ch daiyvaneba unsigned long tipze,<br />

radganac ch/k operaciaSi k - unsigned long tipisaa (wesi 6), Semdeg i<br />

daiyvaneba unsigned long tipze, da mrgval frCxilebSi mocemuli<br />

gamosaxulebis Sedegi iqneba unsigned long tipis. es Sedegi daiyvaneba<br />

double tipze (wesi 3), da mTeli gamosaxulebis tipi iqneba double.<br />

1.5.2. tipebis gardaqmna miniWebisas<br />

miniWebis dros Tu miniWebis operaciis marjvena da marcxena<br />

operandebis tipebi gansxvavdeba, moqmedebs tipebis gardaqmnis martivi<br />

wesi: miniWebis operaciis marjvena mxares mdebare mniSvnelobis tipi<br />

daiyvaneba im cvladis tipze, romelsac eniWeba mniSvneloba.<br />

magaliTad, programa<br />

#include<br />

main()<br />

{<br />

short x=19; char y=125; float z;<br />

z=x+y;<br />

printf("%d %d %d",sizeof(x), sizeof(y), sizeof(x+y));<br />

printf("\n%d %f", sizeof(z), z);<br />

return 0;<br />

}<br />

daabrunebs Sedegs: 2 1 4<br />

4 144.000000<br />

pasuxidan Cans, rom x+y-is mniSvneloba gardaiqmna z-is tipze.<br />

34

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!