0

I have written this code in C:

#include <stdio.h>

int main()
{
    float num = 10.23456f;
    printf("num = %.2f\n",num);
    return 0;
}

I got the output correctly as: 10.23.
But my problem is I do not want to specify the rigid number in the format like %.2f. I want to know if something like this statement occurs or not:

printf("num = %.{n}f\n",num,2); or printf("num = %.{n}f\n",num,5);

Means I can change in printing lively.
Kindly let me know.

Jaffer Wilson
  • 7,029
  • 10
  • 62
  • 139

0 Answers0