What does %d, , %c, %s mean and what's their difference? (VERY BASIC)...im a noobxD
when do I each which?
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"
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.
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
Thanks evveryone!
does is work out for you?
Join our real-time social learning platform and learn together with your friends!