• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

"Backwards reader" program

Joined
Dec 2, 2009
Messages
3,353 (0.59/day)
System Name Dark Stealth
Processor Ryzen 5 5600x
Motherboard Gigabyte B450M Gaming rev 1.0
Cooling Snowman, arctic p12 x2 fans
Memory 16x2 DDR4 Corsair Dominator Pro
Video Card(s) 3080 10gb
Storage 2TB NVME PCIE 4.0 Crucial P3 Plus, 1TB Crucial MX500 SSD, 4TB WD RED HDD
Display(s) HP Omen 34c (34" monitor 3440x1440 165Hz VA panel)
Case Zalman S2
Power Supply Corsair 750TX
Mouse Logitech pro superlight, mx mouse s3, Razer Basiliskx with battery
Keyboard Custom mechanical keyboard tm680
Software Windows 11
Benchmark Scores 70-80 fps 3440x1440 on cyberpunk 2077 max settings
Hi!
I created a stupid program and found it interesting.
So i thought to share!
It reads what you write and displays it on the screen backwards
For example:
tech
hcet
Have a look for yourself:
http://www.mediafire.com/?67lkmi8rdaf7d72
:toast:
 
lol nice :)
How many bytes will that be? Just for curiosity
 
didnt you just use an array and reverse it :p
 
No, i was practicing the for loop!
 
Alek got it right! It's not the simplicity of the concept it's the practice and making a program work, even a simple one, that gives you experience as a coder.
Good job, Alek and thanks for sharing.

Here's your next practice program (it's a classic from almost every programming class) ...
Write a little program that detects if an input string is a palindrome (reads the same forward and backward). It must detect capitalization and punctuation and handle it.

Example :
Input string : "Hello"
Output : "Hello" is not a palindrome"
Input string : "Hello olleH"
Output : "Hello olleH" is a palindrome.

You have ten minutes. GO !! lol

Part #2 : Make general adjustments for phrases.
Input : "do geese see god"
Ouput: "do geese see god" is a palindrome.
 
Here is the code
Code:
for (int i = word.size() - 1; i >= 0; i--)
{
for (int j = 0; j >= word.size() - 1; j++)
{
    if(word.size(j) == word.size(i))
     cout << "palindrome";
    else
     cout << "not a palindrome";
}
}
And no more with the FOR CYCLE!!!
 
You didn't do part #2. No extra credit points for you !! :laugh:
 
what a joke... i was waiting for million dollar compensation....
 
Sounds good to me. I'm a little strapped for cash at the moment so I'll send 1 cent a day to your paypal account for the next 273,790.926 years. :p

What's your next little practice project? Something with pointers perhaps?
 
lol, oh well i am reading a book right now so even if i know the for, if, else and other things i must
read them. So the next project is already made :P
Anyway it is not fun to share stupid projects, but this one made me laugh reading backwards!
It was like a game.
I am interested in solving the part 2 if you can help me of your question, cuz i dont know how to
do it.
[or even a program who reads backwards only if there are syllables]
 
Last edited:
The easiest way is to simply remove all the spaces from the string and then run the palidrome test loop.
Also, if the string is written backward, the same capitalization would apply to make it a correct phrase ("Do geese see God"), so you simply force the string into all lower (or upper) case characters before doing the test loop.
 
Ruby impl.
Code:
some_string = "Do geese see God".upcase.gsub(/ /, "")
if some_string.eql?(some_string.reverse)
    p "is palindrome"
else
    p "is not palindrome"
end
 
I did not find You mentioning what language You were using for this program. Since on one other thread You mentioned trying to learn C++, I will assume that.

#1 can we get the source of that "backwards reader"? I would like to test it out, yet, am too lazy to run an .exe right now.

#2 I don't really get how Your palindrome detector works. Telling what data type "word" is and which size() You are using, would probably help a lot. (there is a whole lot of different implementationts of size() in C++, And, I don't remember a single one that would take any arguments. Hmmm...). (I suppose You would be using string for that word variable. Yet, I should not assume that.)
 
#1 No

#2 string word;

@Aquinus
How bytes does your ruby program need?
Maybe 3 megs? :)
 
That was very !(informative). *sigh* /______/

At least, care to explain how Your palindrome detector works?
 
Last edited:
i have a whole bunch of programs i made while learning C++.

throw a pm if you want them.

source codes are there.
 
That was very !(informative). *sigh* /______/

At least, care to explain how Your palindrome detector works?

He just tossed out code to appease me I think.
It can't possibly work with the code he posted unless nested for loops work completely differntly on his machine. ;)
 
@kreij
I just gave an idea, just like your reply on my question was. I don't really know how to do it.
@Vinska
I didn't give anything cuz you said too lazy to run the .exe
And not lazy for the source code
lol
 
He just tossed out code to appease me I think.
That's what I thought at first. Yet since in any of Your following posts You did not note anything being wrong with that code, I got confused. =|

It can't possibly work with the code he posted unless nested for loops work completely differntly on his machine.

No kiddin'!
...along with: "and if he is also using some custom implementation of size()"
 
Last edited:
The code is this one:
Code:
It was a 1-day trial anyway :)

But to tell you the truth, the real source code, is to learn like a PIG.
I mean, learn a lot and don't forget that everybody will use whatever they
can, distracting you from learning. The worst enemy is yourself.
It is not you who is learning, it is your mind. You just 'manipulate' your mind.
That is the real source code. At least, it works for me!
 
Last edited:
Umm ... Alek? The above code shouldn't even compile.
You get an input string.
Then run a for loop which contains a nested for loop with no execution block (so even if it did compile the for loops do nothing).
Then print out a pair of newlines before calling main again.

We aren't trying to distract you, we're trying to help you.
Just remember that if you are ever coding for a living, there are going to be all kinds of distractions to drive you nuts. :)
 
Copy-Paste in again, i changed a line of code....
Also, want to point out that where i live, C++ is already dead.
So i code for nothing. At least, for now!
 
Alek said:
Also, want to point out that where i live, C++ is already dead.

By that I assume you mean that companies in your area are not looking to hire C++ programmers.
What kind of coders are the companies in your area looking for?
 
Alek, to me the best way to learn was to think like the compiler. that way i can skip on algos and do the programs directly from though, then modify.

i know some ppl who learn it like hell. they lose the creativity :9
 
Back
Top