DEV Community

Sanjar Rashidov
Sanjar Rashidov

Posted on

2 2 2 2 2

setprecision()

Bu funksiya uchun "iomanip" kutubxonasi kerak boladi.

setprecision(x) - bu funksiya kasr sonlarni nuqtadan keyin x ta raqam aniqlikda yaxllitlaydi. ushbu funksiya aytilgan aniqlikda yaxlitlaydi.

C++ odatda float sonlarni yaxlitlagandan keyin ilmiy ko'rinishda ko'rsatadi. Buni togirlash uchun "fixed" kalit so'zi ishlatiladi.

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{

    float kasr = 77.77;

    cout << setprecision(1) << fixed << kasr; 

    return 0;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

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

Okay