To specify right alignment with a width of 5 for an integer in C, you can use the format specifier %5d. Here’s an example:
#include <stdio.h>
int main() {
int number = 42;
printf("%5d\n", number); // This will print the number right-aligned in a field of width 5
return 0;
}
In this example, the integer 42 will be printed with spaces padding it on the left to ensure the total width is 5 characters.
