0
Int to string
1 = freshman 2 = sophomore 3 = junior 4 = senior 5 = senior I need an int input and print it to word Example Input =1 (must be int) Print= freshman
8 Respostas
+ 2
Yes that sounds the right way, as long as you remember to add break at end of each case😉
+ 3
switch-case
https://www.sololearn.com/learn/CPlusPlus/1618/
Try it, if you still can't work out your homework, come back with a code attempt
+ 1
If you like, I can give you an assignment to enhance your understanding.
0
thanks. what I did is i put some cout inside the case using the switch statement.
0
Gordon you want to check my activity for this question?
0
No need
I think you already achieved the problem in your question, isn't it?
If you get the right result, then the code works and it is good. No need to inspect it.
I am trying to guide you to progress in coding skill.
If you don't mind, try this slightly different one:
For Mark above or equal 95, output "Distinction!"
For Mark between 40 and 94, output "Passed"
For Mark below or equal 39, output "Failed"
Code two versions, first one is using if else statements
Second version is using switch.
How to use switch-case statement to handle a range is a threshold to many programmer. You need to have a programmer's mindset in solving this problem.
0
Gordon happy to do this activity. I’ll get back to you once I’m done.
0
hi Gordon It’s been a while. using if else statement.
https://code.sololearn.com/co4V1qggPNE1/?ref=app