Showing posts with label float. Show all posts
Showing posts with label float. Show all posts

Wednesday, May 16, 2018

C program to print a fractional number after rounding it to two decimal places.

Program code
#include <stdio.h>
#include <conio.h>
void main()
{
float a;
clrscr();
printf("Please insert a number.\n");
scanf("%f",&a);
printf("The number you have entered is %.2f",a);
getch();
}

Example of output
Please insert a number.
7.7777
The number you have entered is 7.78