How to print a number with specified decimal places ?

This can achieved through the use of suppression char ‘*’ in the format string of printf( ) which is shown in the following program.

main( )

{

int  p  =  2 ;

float  n  =  12.126487687 ;

printf ( “%.*f”,p, n ) ;

}

Subscribe / Share

It's very calm over here, why not leave a comment?

Leave a Reply




Categories

Powered by Yahoo! Answers