DEV Community

BUTTSAN
BUTTSAN

Posted on

Assalomu aleykum 13.08.24 biz c++ codlash tilida 5 darsimizni otdik va bu men tushungan narsalarim.

birinchisi biz uchta kutubhona chakiramiz ikinchisi esa ikta verible yaratamiz va unga nom beramiz
va ularga kiymat beramiz bu son kelgin esa ularni hohishingizga karab yoki koshasiz yoki ayirasiz
yana oz hohishizga qarab ularga boshqa son ham berisingiz mumkin pasta korib turibsiz va ohiriga cout kilamiz

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;
int main(){
int a = 5, b= 7;

Enter fullscreen mode Exit fullscreen mode
Enter fullscreen mode Exit fullscreen mode

kelgisi
bu cod 5 honali sonni yaxlitlab beradi masalan input; 13900,
yozilsa 14000 chiqazadi.

int main (){
    int son ;
    cin >> son;

    float newSon = son;
    cout << round(newSon / 1000) * 1000;

    return 0;
}

Enter fullscreen mode Exit fullscreen mode

bu cod birorta sonni necha soat , necha minut , necha secund ekanligini chiqazib beradi.

int main (){
    int secund;
    cin >> secund;
    cout << setw(2) << setfill ('0') << secund / 3600 << ":"; 
    cout << setw(2) << setfill ('0') << secund % 3600 / 60 << ":"; 
    cout << setw(2) << setfill ('0') << secund % 60 << ":"; 

    return 0;

}
Enter fullscreen mode Exit fullscreen mode

va shu bilan men sizlar bilan hayirlashaman

Top comments (0)