DEV Community

Rivojiddin
Rivojiddin

Posted on

Foundationda 3 - dars

Bu kodda bir honali son kiritilsa sonni chap tomoniga nol qo'shib beradi.


int main () {

 int son ;

 cin >> son;

 cout << setw(2) << setfill('0') << son;

 return 0;
Enter fullscreen mode Exit fullscreen mode

}

bu kod int belgini charga aylantirib beradi.


int main () {

int belgi;

cin >> belgi;

cout << char(belgi);

return 0;
Enter fullscreen mode Exit fullscreen mode

}

bu kod char belgini intga aylantirib beradi.


int main () {

char belgi;

cin >> belgi;

cout << int(belgi);

return 0;
Enter fullscreen mode Exit fullscreen mode

}
roundni vazifasi sonni yaxlitlab beradi.


int main (){

float kasr = 12.5;

cout << round (kasr) << endl;

return 0;
Enter fullscreen mode Exit fullscreen mode

}

bu kod 10 ta fibonacci sonni chiqarib beradi.


int main() {
int a = 0, b = 1;
for (int i = 0; i < 10; i++) {
cout << a << " ";
int c = a + b;
a = b;
b = c;
}
return 0;
}

Top comments (0)