printf() examples/variations in C
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
1) Print normal text
Output
2) Print text in new line
Output
3) Print double quote
To print double quote, we use ".
Output
4) Print percentage sign (%)
To print percentage sign/ character, we use %%.
Output
5) Print octal value
To print octal value, we use %o (It's alphabet o in lowercase)
Output
6) Print hexadecimal value (with lowercase alphabets)
To print hexadecimal value, we use %x (its alphabet 'x' in lowercase) - as we know that a hexadecimal value contains digits from 0 to 9 and alphabets A to F, "%x" prints the alphabets in lowercase.
Output
7) Print hexadecimal value (with uppercase alphabets)
To print hexadecimal value, we use %X (it's alphabet X in uppercase) - as we know that a hexadecimal value contains digits from o to 9 and alphabets A to F, "%X" prints the alphabets in uppercase.
Output
8) Print long string using \ (slash)
If there is a long string, that you want to print with a single printf() with two or more lines, we can use slash (\).
Output
9) Print backslash (\)
To print backslash (\), we use double backslash (\\).
Output
10) To get total number of printed characters
We can also get the total number of printed character using printf(), printf() returns the total number of printed character, that we can store in a variable and print.
Output
need an explanation for this answer? contact us directly to get an explanation for this answer