Why does the while loop condition check == 'y'?

  • Thread starter Thread starter chetzread
  • Start date Start date
  • Tags Tags
    Loop
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
chetzread
Messages
798
Reaction score
1

Homework Statement


for the circled part , why there's again =='y' ? i didnt see the variable 'y' anywhere other than the circled part ...What does it mean ?

Homework Equations

The Attempt at a Solution


Is the code wrong ?
 

Attachments

  • 1.PNG
    1.PNG
    11.9 KB · Views: 420
Physics news on Phys.org
Characters in quotes are character constants. The statement in question is checking whether the user has input a 'Y' or a 'y' (so that both upper and lower case are checked).
 
@chetzread, before you learned about loops and other control structures, there was probably some mention about the various types of constants that can be used in C. At least most of the books I've seen present such material in that order.

Character constants, such as 'y' or 'B' or '\t'
String constants, such as "cat"
integer constants, such as 23, 023, and 0x23 (all with different values)
floating point constants, such as 2.7 (a double) and 3.09F (a float)
This is not meant to be an exhaustive list.