I want to use a variable with an input value as the number of decimal places in C. The IDE that I'm using is CodeBlocks in Windows. Here's an example of the code that I tried to make (this is an example):
#include <stdio.h>
int main()
{
int value;
float number;
printf("Enter a number (float).\n");
scanf("%f", &number);
printf("Enter a value.\n");
scanf("%d", &value);
// here I'm trying to use the input value (float number) with the decimal places value (int value).
// In %.%df I'm trying to use the variable int value as the decimal places number
// (example: %.2f, being 2 the decimal places number) even though it is an int variable.
printf("The number %f with %d decimal places is %.%df.\n",
number, value, number, value);
return 0;
}