Within the C programming language, you should use the printf() operate to print textual content and variables to the console. The printf() operate takes a format string as its first argument, which specifies how the output needs to be formatted. The format string can include placeholders for variables, that are represented by % characters adopted by a sort specifier. For instance, the next code prints the worth of the variable ‘x’ as an integer:
printf(“The worth of x is %dn”, x);
It’s also possible to use the printf() operate to print variables in colour. To do that, you have to use the %c escape sequence, adopted by a colour code. The next desk lists the colour codes that you should use:
Shade | Code |
---|---|
Black | 33[0m |
Purple | 33[31m |
Inexperienced | 33[32m |
Yellow | 33[33m |
Blue | 33[34m |
Magenta | 33[35m |
Cyan | 33[36m |
White | 33[37m |
For instance, the next code prints the worth of the variable ‘x’ in crimson:
printf(“