How to compare case sensitivity for characters in an array? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to compare case sensitivity for characters in an array?

input1: Size of array 3 Enter charcters1 a Output 1: Invalid Input 2: Size of array 3 Enter characters 1 A B B Enter characters 2 A A C Output 2: Matched values are 1

18th Sep 2020, 2:28 PM
Roshini Balivada
5 Answers
+ 7
Can you try your best:)) if you go wrong anywhere definetly we will help you but ,directly giving tasks isn't that good:) edit: hint: use ascii value of charecter1 and characters2 so it will be int then minus both charecters using loops ...if the minus gives 0 then they are equal and keep the count
18th Sep 2020, 2:33 PM
chaithra Gowda
chaithra Gowda - avatar
+ 1
In those two arrays character 1 and character 2,only A is getting matched so output is 1.and my issue is if input character is a lower case letter, program should get terminated leaving a message as invalid, there is a condition not to use system.exit() to terminate program.i tried if char is between 'A' to 'Z' ,it didn't work for me.
18th Sep 2020, 3:11 PM
Roshini Balivada
0
You mean if a charecter is Capital letter or not..? If yes then, you can check capital letter ascci values 65 to 90 or direcltly if chr is in between 'A' and 'Z' or not... Edit : Pls post your try..
18th Sep 2020, 2:33 PM
Jayakrishna 🇮🇳
0
How come matched values are 1? could you be more descriptive about this, what are being compared, how they are compared, and what is to be returned by comparison function.
18th Sep 2020, 2:34 PM
Ipang
0
Roshini show the code of yours. That's help to find why not working... You can use break statement from loops to stop.
18th Sep 2020, 9:17 PM
Jayakrishna 🇮🇳