Write a program that rounds a real number entered on the keyboard to two digits after the decimal point.


Difficulty level
This exercise is mostly suitable for students
#include <stdio.h>

int main()
{
    double nb;
    
    printf("Enter a real number: ");
    scanf("%lf", &nb);
    nb=((int)(nb*100))/100.0;
    printf("Number rounded to 2 digits after the decimal point %lf \n", nb);
    
    return 0;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
9th complement