DEV Community

Cover image for Type casting | C++
Imron
Imron

Posted on

Type casting | C++

Type Casting – C++ (Foundation)

Type casting – bir turdagi ma’lumotni boshqa turga o‘zgartirish.

1️⃣ Implicit (avtomatik) casting

Kompilyator o‘zi o‘zgartiradi.

int a = 5;
double b = a;   // int -> double

Enter fullscreen mode Exit fullscreen mode

2️⃣ Explicit (qo‘lda) casting

Dasturchi o‘zi o‘zgartiradi.

double x = 5.7;
int y = (int)x;   // 5 bo‘ladi

Enter fullscreen mode Exit fullscreen mode

Double dan int ga o'tkazganda biz ma'lumotni kismini yoqatamiz.

Top comments (0)