0
what is the reason of using %s ???
4 Answers
+ 1
To print the string.Basically string is a char array so to print array we have to used arr[] index to access all element we use loop intead of this whole process we can just use %s at the time of printing.
0
I am still confused. It seems like %s was never needed before this lesson to printf a sentence. The %s doesn't seem to be calling to an array to pull in any stored data that is used for the output. Why is this necessary here?
The code in questions is:
int score = 89;
if (score >= 90)
printf("%s", "Top 10%\n");
else if (score >= 80)
printf("%s", "Top 20%\n");
else if (score > 75)
printf("%s", "You passed.\n");
else
printf("%s", "You did not pass.\n");