DEV Community

Sanjar Rashidov
Sanjar Rashidov

Posted on

Variables & Data types

Variables - O'zgaruvchi kompyuterni xotirasida ma'lum bir qiymatlarni saqlash uchun kerak bo'ladi.

Data types - Ma'lumot turlari.

Quydagi data typelar butun sonlar uchun ishlatiladi:
1.int
2.long
3.short

Quydagi data typelar kasr sonlar uchun ishlatiladi:
1.double
2.float
Double _float_dan xotira jihatdan kottaroq

Quydagi data typelar tekst va matnlar uchun ishlatiladi:
1.string

Quydagi data typelar belgilar uchun ishlatiladi:
1.char

DATA TYPELARNI XOTIRADAN OLADIGAN JOYI

  • int -> 4 byte
  • long -> 8 byte
  • short -> 2 byte
  • double -> 8 byte
  • float -> 4 byte
  • string -> 32 byte
  • char -> 1 byte
#include <iostream>

using namespace std;

int main()
{
    int son1 = 20;
    long son2 = 123;
    short son3 n = 4;
    double kasr1 = 123.4;
    float kasr2 = 12.3;
    string ism = "Bobur";
    char belgi = '$';

    cout << son1 << endl;
    cout << son2 << endl;
    cout << son3 << endl;
    cout << kasr1 << endl;
    cout << kasr2 << endl;
    cout << ism << endl;
    cout << belgi << endl;

    return 0;
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)