c program

2007-10-19 4:59 am
write printf statement so that the following sentences appear on the screen of a computer.
a)a "string"is made up of characters
b)the price is increased by10%
c)the character \nis to start a new line
d)%5.2fmeans the minimum lenght is 5 and decimal place is12
f)an example of charcater is 'A'

回答 (1)

2007-10-21 11:10 am
✔ 最佳答案
The following code will do what is requested, including minor spelling corrections. However, Yahoo modifies some single characters (example " in the question), so some adjustments may have to be made.

/* a backslash is used to print special characters, such as the double quote */
printf("a \"string\" is made up of characters\n");
/* % has to be doubled to distinguish from the format specifications */
printf("the price is increased by 10%%\n");
/* the backslash has to be "protected" by another backslash */
printf("the character \\n is to start a new line\n");
/* Again, % has to be doubled to print properly */
printf("%%5.2f means the minimum length is 5 and decimal place is 2\n");
/* nothing needs to be done to print the single quote */
printf("an example of charcater is 'A'\n");


收錄日期: 2021-04-13 13:59:56
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20071018000051KK03337

檢視 Wayback Machine 備份