Data Types (Type Conversion)
Firdavs Mukhsimov
Posted on October 16, 2024
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`
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.
💖 💪 🙅 🚩
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
githubcopilot AI Innovations at Microsoft Ignite 2024 What You Need to Know (Part 2)
November 29, 2024