0
I am in trouble due to one question, can anyone help me to solve that?
Write a program to print 'F' to 'A' in five different lines.
5 Respostas
+ 8
Anonymous ,
please link your code attempt here.
+ 3
1. Learn to use a loop, it can either be a while...loop or for...loop. Understand how to make the loop counter counts backwards instead of forward
2. Look up the net for a function named `chr` it will definitely help you in this task
Come show your code when you got it all figured out
+ 2
Anonymous,
I will assume you know ASCII codes, also remember ASCII code of letter 'A' is 65 and ASCII code of letter 'F' is 70.
Function chr () takes a numeric argument and it can accept ASCII or Unicode values.
The loop I was suggesting you to make was one that goes backwards from 70 down to 65, You can print return value from chr () within the loop body.
Now you see why the loop has to go backwards ...
+ 2
Your request doesn't make sense. This problem can be solved with a single line of code. Why do you need it to be exactly 5 lines?
Or if you mean the output should be on separate lines for each letter, then I want to point out that from F to A there are six letters. So you may want to skip a letter, or write two letters in the same line, or your specification is misleading :)
+ 1
Ipang I know loops, but I don't know how to apply char function in this program. I need your more help to solve this problem.