Accept the Float Value and Precision Value and Print the Float Value According to the Precision Given - Learn Engineering

All the news and updates relevant to Engineering. You can also Write a post here

Breaking

Monday, May 25, 2020

Accept the Float Value and Precision Value and Print the Float Value According to the Precision Given


Question:

Accept the Float Value and Precision Value and Print the Float Value According to the  Precision Given.

TestCase InputExpected Output

15.87 6 15.870000

12.3 312.300

Answer:

#include<stdio.h>
int main()
{
  float num;
  int precision;
  scanf("%f %d",&num,&precision);
  printf("%.*f",num,precision);
  return 0;
}

Follow Us for More..

1 comment: