What is %a %f etc in variables. | SoloLearn: Learn to code for FREE!


What is %a %f etc in variables.

I don't get why these are necessary in variables

11/21/2020 10:10:30 AM

Alex Mih

7 Answers

New Answer


Each format specify each type of variable. For example, %f is for float. So if you need to put a float variable into the string, use it like "My float: %f". And put the variable at another paremeter. For example, printf("My float: %f, theFloatVariable); You also need format specifier for scanf.


Refer to http://www.cplusplus.com/reference/cstdio/printf/ for an explanation of format specifiers used with printf(). Format specifiers are also used with other input and output functions such as: fprintf, sprintf, scanf, fscanf, and sscanf.


They are format specifier. When you need to put variables into the string. You need to use them.


Thank you


CarrieForle %a and %A does exist, but I forgot when it's added.


LastSecond959 after some searching I found out %a actually exists. Thanks for your correction. Here is what I found: %a was added in C99. It is used to display a hexadecimal (16 based) of a float and double. And so was %A.


Thank you. But what formats do they specify