DEV Community

etibor2006
etibor2006

Posted on

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

Top comments (1)

Collapse
 
dawroun profile image
Davron

zo'r