Data Types (Type Conversion)

firdavs_mukhsimov_9f62550

Firdavs Mukhsimov

Posted on October 16, 2024

Data Types (Type Conversion)

a) Implicit va Explicit turdagi konversiyalar
o'rtasidagi farq nima?

Implicit (Bevosita) o'zgarish: Kichik hajmdagi 
qiymatlarni katta hajmdagi qiymat turlariga osonlik 
bilan o'zgartirish mumkin.

- Masalan: `int` -> `long` yoki `float` -> `double`
Explicit (Aniq) o'zgarish: Bu o'zgarish katta hajmdagi 
qiymatni kichik hajmdagi qiymatga o'zgartirishda amalga 
oshiriladi. Ular uchun maxsus casting kerak bo'ladi.

- Masalan: `double` -> `int`
Enter fullscreen mode Exit fullscreen mode

b) Quyidagi kod qaysi turdagi konversiyalarni
amalga oshiradi?

int x = 10;
double y = x;

*Javob: * int -> double Implicit

Bu yerda int ni double da o'zgartirsa bo'ladi ammo 
doubleni int tipiga o'zgartirib bo'lmaydi.
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
firdavs_mukhsimov_9f62550
Firdavs Mukhsimov

Posted on October 16, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related