why use % two times in if statement after top 10 when result show one time %, what is the mean of second percentage? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why use % two times in if statement after top 10 when result show one time %, what is the mean of second percentage?

int main() { int score = 91; if (score >= 90) printf("Top 10%%.\n"); else printf("Less than 90.\n"); return 0; }

13th Mar 2020, 7:32 PM
Jitendra Kumar
Jitendra Kumar - avatar
1 Answer
+ 1
You dont need there.. It's your string which you want to output. In printf function, text between " ", every character are printed as it is except escape sequence characters such as \n \t, and %d, %f. These are replaced by its corresponding values and arguments.. Read about escape charecters in c. And Ex: int rank=1; printf(" Your Rank =%d", rank) ; Output is Your Rank=1.//%d is replaced by rank value.. But in your example it is your choice of writing twice only.. printf("%%%%%") ; for this, Output is %%%%% only,, observe difference..
13th Mar 2020, 8:32 PM
Jayakrishna 🇮🇳