Encryption and Decryption | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Encryption and Decryption

Can you please help on how to stop my code from running an infinity loop ,I want it to stop when I insert -1 https://sololearn.com/compiler-playground/cGXVqi1LON39/?ref=app

24th Apr 2024, 5:16 PM
Sbusiso Ndunge
Sbusiso Ndunge - avatar
5 Answers
+ 2
It didn't run as an infinite loop when I did it. What compiler are you using? If it's the Sololearn compiler, you can't do real-time input. Each input needs a new line, I wrote: encrypt 6 Here's my message -1 And the program printed out the questions for input and then my message as a series of numbers. Is that correct? https://www.sololearn.com/discuss/1042235/?ref=app https://www.sololearn.com/discuss/1382494/?ref=app https://www.sololearn.com/discuss/1515993/?ref=app
24th Apr 2024, 5:34 PM
Ausgrindtube
Ausgrindtube - avatar
0
I was using visual studio code,to me it kept on running as an infinity loop, which one you were using?Yes that's how it's supposed to work when you enter encrypt and type the base you want to convert your message to a decimal and vice versa.
25th Apr 2024, 10:34 AM
Sbusiso Ndunge
Sbusiso Ndunge - avatar
0
I used the Sololearn compiler with your code and as I said, I entered the information as above, on new lines. The infinite loop occurs if you don't enter -1, correct? That's the point, right?
26th Apr 2024, 6:59 AM
Ausgrindtube
Ausgrindtube - avatar
0
Yes that's correct.
26th Apr 2024, 9:23 AM
Sbusiso Ndunge
Sbusiso Ndunge - avatar
0
And so, when you enter the -1, or anything less than 0, it should stop the program.
26th Apr 2024, 11:24 AM
Ausgrindtube
Ausgrindtube - avatar