# hmm, easy problem from by book.

• 01-07-2003
Vber
hmm, easy problem from by book.
Hello guys ;)

I'am reading a book, and I do need to build a program that doe's the following things:

Collect an logical statement:
> (11 == 11) || (0 > 2)

Return's true or false:
> TRUE

Translate the statement:
(11 EQ 11) OR (6 LT 11)

Here is the table:
== : EQ
<= : LE
&& : AND
> : GT
>= : GE
| | : OR
< : LT
~ : NOT
!= : NE

Now, I don't know from where to start.
I don't want that guys write out all my code (or part of it)

I just need some help understanding the problem, thanks.
• 01-07-2003
Cshot
The problem can be broken into two parts.
1) translating the line
2) returning the boolean value of the statement

I suggest you tackle part 1 first. This is rather straight forward. Parentheses and numbers do not get translated. So really, all you have to watch is the ==, !=, etc.
You can do this by just scanning characters and printing them out as you go.

Part 2 is a bit trickier. I suggest you do some research about precedence of operators, stacks, and recursion.
• 01-07-2003
Vber
Ok, I'll break the problem in two parts.
Now, translating the sentence, should I get all the sentence as a string and then start translating right?
• 01-07-2003
Cshot
Yup. After you get that part, then you can try cases such as:

(11 == 11) || (0 > 2)
(11==11)||(0 >2)
( 11 == 11)||(0 > 2)
etc...
• 01-07-2003
Vber
Ok, thanks for helping.
I'll try to complete this exercise.
anyway I think I'll need some help during solving the problem :)

Thank you very much. ;)
• 01-07-2003
immeraufdemhund
one quick little note about english about a and an. a is used when the next words first letter is a constanant (sp??) and an is used when a vowel shows up....not really important, but i didn't know untill 10th grade.... (i saw someone use it wrong on this thread)...

to programming though.
there is one command in the string.h library. It's called
Code:

```strstr(char *s1, char *s2) s1 = string to look at s2 = string to look for in s1```
it will find the first instance of a string say >, <, == etc. this will just help you to determain if your done looking at the string. Or one thing that you could do is go through char by char and see if it's one of the operators. If it is then determain which one and change it to the appropriate sign. Show us what you got.
• 01-07-2003
ronin
Along with strstr as mentioned by immeraufdemhund, this *might* be handy at some point.

char *cptr;
int found;

cptr = strstr(stringVAR, "hunted for in stringVAR");
found = cptr - stringVAR + 1;

English
determine
I
comma usage
you are or you're
:D
• 01-07-2003
Vber
Ok, thanks guys :)
thanks.