Input an integer value and print with padding by Zeros in C
Input an integer value and we have to pad the value by Zeros in C.
Example:
Input:
Enter an integer value: 12
Output:
2 digit padding: 12
3 digit padding: 012
4 digit padding: 0012
To print with padding by Zeros, we use the following format specifier with the printf() statement,
- %d : No padding
- %01d : 1 digit padding with zeros
- %02d : 2 digits padding with zeros
- %03d : 4 digits padding with zeros
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer