Ask your own question, for FREE!
Computer Science 12 Online
OpenStudy (pottersheep):

What does %d, , %c, %s mean and what's their difference? (VERY BASIC)...im a noobxD

OpenStudy (pottersheep):

when do I each which?

OpenStudy (airdawg5571):

They're all placeholders for variables. %d is decimal (basically, numbers), %c is for char (only one character) and %s is for strings. For example: printf("Variable 1 is %d and variable 2 is %d",i,j); in this text the first %d is replaced with the value of variable i (let's say an integer)and the second %d with the value of variable j (also a numeral type of variable). The output would be something like "Variable 1 is 5 and variable 2 is 27"

OpenStudy (rsmith6559):

They are placeholders for formatted input/output. %d is for integers, %f or %g are for floating point numbers. If you take a look at the printf man page, it will explain in more detail what all you can do.

OpenStudy (anonymous):

hello,I think %d is used to indicate that the data type to be input is of type 'integer' %c is used to input a single character into the program using the input function 'scanf' in case of C programming %s inputs a string of characters into the program

OpenStudy (pottersheep):

Thanks evveryone!

OpenStudy (anonymous):

does is work out for you?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!