PLEASE EXPLAIN ! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

PLEASE EXPLAIN !

Can any one explain me in detail what are %d,%f,%c in C language !

14th Jan 2019, 5:19 AM
Prathamesh Kulkarni
1 Answer
+ 7
In C programming language, printf() function is used to print the “character, string, float, integer, octal and hexadecimal values” onto the output screen. %d, %f, etc - they are format specifiers. %d - we use it to display integer variables -||- = i use it to replace "we use it to display" %f - -||- floating variables %c - -||- character variables %s - -||- string variables %lf - -||- double variables %x - -||- hexa zecimal variables when you try to print to the screen in this scenario: char h = "a"; printf ("This is the character h i was talking about"); it will print the string as it sees it, but perhaps you wanted it to print "a" instead of "h" because the last one you passed it as a variable. To do that you can use the %c format specifier like this: char h = "a"; printf ("This is the character %c i was talking about", h); As you can see after the string to be printed on the screen i put a comma "," and then i specified with what character variable to replace the %c format specifier. Hope this helped you
14th Jan 2019, 5:57 AM
notqueued
notqueued - avatar