C - Write program to round 3.1415 to 3.142 during output

Requirements

Write program to round 3.1415 to 3.142 during output

Hint

The printf format can do the rounding during outputing float numbers.

Demo

#include <stdio.h>

int main()//  w  w w  .jav  a  2 s .  c  o m
{
    printf("%1.3f\n",3.1415926535);
    return(0);
}

Result

Related Exercise