DEV Community

Mohira21
Mohira21

Posted on

6 2

C++ | Variables and date types

Data types

Int :

short, long, int (butun sonlar);

Real number :

float, double (kasr sonlar);

Character :

char (belgilar).

int age=14;
cout << age + 5 * 26 << endl; (144)
age= -15
Enter fullscreen mode Exit fullscreen mode

Declaration

  • bu o'zgaruvchilarni e'lon qilish;
int height;
weight double;
float radius;
Enter fullscreen mode Exit fullscreen mode

keywords

  • int, double,float ...
    • cannot use as identifiers.

Assignment

  • bu o'zgaruvchiga qiymat o'zgartirish;
son=25;
Enter fullscreen mode Exit fullscreen mode

Initalization

  • o'zgaruvchini e'lon qiish vaqtida birdaniga qiymat berish;
int 6 = 16;
Enter fullscreen mode Exit fullscreen mode

O'zgaruvchi nomi harflar, raqamlar va _ belgisidan iborat bo'lishi kerak.

int a=5;
int b=a;
int c=a+b;
int a;
float b; int a,c;
int c; float b,d;
float d;
Enter fullscreen mode Exit fullscreen mode

Garbage value

  • declaration kiritilsayu, o'zgaruvchi miqdori kiritilmasa councilda chiqadigan taxminiy sonlar
   int a= 123.45 --> 123
   float a= 123 --> 123.00
Enter fullscreen mode Exit fullscreen mode
int vazn = (int)[majburlash] 120.123

int a=10;
int b= a+10;
int c= a+b;int d+ a+b+c;

a=b=c=d=60
Enter fullscreen mode Exit fullscreen mode

cin >>

  • o'zgaruvchini o'qiydigan komanda
    • char --> Ascii table
char belgi= 'a'

cout << (char) (belgi/3) << endl; [majburlash]
Enter fullscreen mode Exit fullscreen mode

iomanip

  • input output manipulation, kutubxona

setw()

  • o'zgaruvchi uchun print qlishda bo'sh katakchalar so'raydi
cout << setw(15) << son << endl; [by default right-aligned]
cout << left << setw (15) << son << endl;
```



## `setfill('')`
- `setw()` orqali ajratilgan yacheykalarni belgilar bn to'ldiradi
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay