The correct answer is: A. bitwise OR operator(|)
Format flags are combined using the bitwise OR operator(|) to specify multiple formats for a single output field. For example, the following code will format the output field to be both left-aligned and right-justified:
printf("%-10s", "Hello, world!");
The %-10s
format specifier indicates that the output field should be left-aligned and have a width of 10 characters. The |
operator combines the %-10s
format specifier with the %s
format specifier, which indicates that the output field should be right-justified. The result is that the output field will be left-aligned and have a width of 10 characters, but the text will be right-justified within that width.
The other options are incorrect because they are not used to combine format flags. The logical OR operator (||) is used to combine two boolean expressions, and the bitwise AND operator (&) is used to combine two binary numbers. The logical AND operator (&&) is used to combine two boolean expressions and only return true if both expressions are true.