In getting some question marks inside boxes in case of space' ' . Can anyone please explain why I'm getting that and how to solv | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

In getting some question marks inside boxes in case of space' ' . Can anyone please explain why I'm getting that and how to solv

https://code.sololearn.com/cD8YF10R1M0F/?ref=app #include <iostream> using namespace std; int main() { string c; getline(cin,c); int u = c.length(); for(int i = 0;i<u; i++){ if((int)c[i]<90){ int v = (int)c[i]-65; int o = 122-v; cout<<(char)o; } else if((int)c[i]<122){ int v = (int)c[i]-97; int o = 122-v; cout<<(char)o; } else cout<<c[i]; } return 0; }

10th Jan 2021, 7:34 AM
Nazeefa Labiba
Nazeefa Labiba - avatar
3 Answers
+ 3
Space has ascci value is 32. so 1st if condition (int)c[i]<90 becomes to true so it will also converted. You should check value in between 65 to 90 or 97 to 122 (not only for less than.) or use if char is not a space in 1st if, and do the next by else if...
10th Jan 2021, 9:39 AM
Jayakrishna 🇮🇳
+ 2
You're welcome...
10th Jan 2021, 10:57 AM
Jayakrishna 🇮🇳
+ 1
Thanks a lot for the answer😊
10th Jan 2021, 10:05 AM
Nazeefa Labiba
Nazeefa Labiba - avatar