DEV Community

etibor2006
etibor2006

Posted on

2

CHAR VA BOOL HAQIDA MA'LUMOT.

Char sozi charactersozini qisqartmasi.
Char biror bir soni yokida belgini, harfni bittali '' ichiga begilab qoyishimiz mumkin.Undan ortiq belgilarni saqlab qo'ya olmimiz.Faqatgina bir dona belgi saqlash mumkin.

 int a =10;
  float b =10.5;
  double c =10.2536488;
  string d = "ikkichilar";

  // char => character (belgi);

  char belgi = 65;
  int son = 'A';
  //int son = 3;

 cout << belgi << " " << son;


  return 0;
}
Enter fullscreen mode Exit fullscreen mode

Butun son bilan belgini o'rnini o'zgartishimiz ham mumkin. Misol uchun

int a = 65;
char b = 'z';

cout<< char (a);
cout << endl << int (b);

  return 0;
}
Enter fullscreen mode Exit fullscreen mode

Bool bu booleansozini qisqartmasi.True-False ya'ni tori yoki notog'riligini bilishimiz mumkin.True 1 ga teng.False esa 0 ga teng.

// bool => boolean
  bool a = true;
  cout << (10 < 5);
 return 0;
  }
Enter fullscreen mode Exit fullscreen mode

Sonlarni yahlitlash uchun niz yangi bir kutubxona chaqaramiz.Bu kutubxonani nomi <cmath>buni ichidan bizga kerakak bo'ladi round.

#include <iostream>
#include <cmath>
using namespace std;
int main5 (){
 float a;
  cin>>a;
  cout << round(a);
  return 0;
}
Enter fullscreen mode Exit fullscreen mode

ASCIIjadvalida katta harflarA~Zva kichik harflara~zketma-ket joylashtirilgan. Ushbu hususiyatdan foydalanib bitta kichik harf qabul qiling va katta harfga convert qilib chop etishni o'rganamiz.

 char c = 97-32;


 cout << c ;

  return 0;
}
Enter fullscreen mode Exit fullscreen mode
#include <iostream>
#include <cmath>
using namespace std;
int main7 (){
  char a;
  cin >> a;


 cout << char (a - 32) ;

  return 0;
}
Enter fullscreen mode Exit fullscreen mode

@dawroun

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (1)

Collapse
 
dawroun profile image
Davron

zo'r

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

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

Okay