473,506 Members | 16,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

example of a logic bug using pseudocode

I want run this by the group for correctness.
The question is as follows:

9. Present an example of a logic bug using pseudocode and explain your
answer. (10 points)
Temperature = 70
if (Temperature >69) and (Temperature < 100 )
THEN
openWindows;
Will work because if temperature is higher than 69 degrees and
temperature is lower than 100 degrees windows will open.
2. Gentlemen, after reading your advise I had run the code in C++,
then stated it back in pseudocode. I suppose the programmer could
mistakenly use the "AND" && operator instead of the "OR" || operator
which I found the latter to run a loop which I couldn't end, not even
with a ctrl-c, and had to push the power button in to turn off my
computer (please keep that in mind). Also found that the temperatures
reflected would better reflect opening the windows and not closing
them.

Temperature = 70
if (Temperature >69) and (Temperature < 100 )
THEN
openWindows;
Will work because if temperature is higher than 69 degrees and
temperature is lower than 100 degrees windows will open.

The code generated: numbered list 70-99

------------------------------------------------------------------------------------------------------------------------------------------------------

Temperature = 70
if (Temperature >69) or (Temperature < 100 )
THEN
openWindows;

Won't work because windows will stay closed due to temperature will
always be under 100 degrees the fault lies with the "or" "||" operator
which was used instead of the "and" (&&) operator.
The code generated: an infinite loop of never ending numbers that
crashed my computer.

Thank You,

Ray The code generated: numbered list

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Temperature = 70
if (Temperature >69) or (Temperature < 100 )
THEN
openWindows;

Won't work because windows will stay closed due to temperature will
always be under 100 degrees the fault lies with the "or" "||" operator
which was used instead of the "and" (&&) operator.
The code generated: an infinite loop of never ending numbers that
crashed my computer.

Thank You,

Ray
Jul 22 '08 #1
7 2456
popeyerayaz said:

<snip>
I suppose the programmer could
mistakenly use the "AND" && operator instead of the "OR" || operator
which I found the latter to run a loop which I couldn't end, not even
with a ctrl-c, and had to push the power button in to turn off my
computer (please keep that in mind).
Modern multi-tasking computer systems generally provide some way to
terminate a process from outside the process itself. For example, on
Windows you could have brought up the Task Manager (Ctrl-Alt-Del
nowadays), identified the process, selected it, and terminated it. Under
Linux, you could have used ps -eaf | grep <tasknameto find the task's
process ID (pid) and then used kill -9 <pidto terminate the task.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 22 '08 #2
On 22 Jul, 06:55, popeyerayaz <popeyera...@gmail.comwrote:

your post is very confusing
I want run this by the group for correctness.
The question is as follows:

9. Present an example of a logic bug using pseudocode and explain your
answer. (10 points)

Temperature = 70
*if (Temperature >69) and (Temperature < 100 )
* * * * THEN
* * openWindows;
else
openLinux

:-)

Will work because if temperature is higher than 69 degrees and
temperature is lower than 100 degrees windows will open.
2. Gentlemen, after reading your advise [advice?] I had run the code in C++,
what gentlemen? what advice?

then stated it back in pseudocode. I suppose the programmer could
mistakenly use the "AND" && operator instead of the "OR" || operator
which I found the latter to run a loop which I couldn't end,
how the hell can the above p-code loop??!

not even
with a ctrl-c, and had to push the power button in to turn off my
computer (please keep that in mind).
I think you need a new computer.
Also found that the temperatures
reflected would better reflect opening the windows and not closing
them.
what does "temperature reflected" mean? The code you've posted
doesn't close windows.

Temperature = 70
*if (Temperature >69) and (Temperature < 100 )
* * * * THEN
* * openWindows;
Will work because if temperature is higher than 69 degrees and
temperature is lower than 100 degrees windows will open.
why did you post this twice?

The code generated: numbered list 70-99
what?

---------------------------------------------------------------------------*---------------------------------------------------------------------------

Temperature = 70
*if (Temperature >69) or (Temperature < 100 )
* * * * THEN
* *openWindows;

Won't work because windows will stay closed due to temperature will
always be under 100 degrees the fault lies with the "or" "||" operator
which was used instead of the "and" (&&) operator.
The code generated: *an infinite loop of never ending numbers that
crashed my computer.
there is no loop in the above code
Thank You,

Ray The code generated: numbered list

---------------------------------------------------------------------------*---------------------------------------------------------------------------*---------------------------

Temperature = 70
*if (Temperature >69) or (Temperature < 100 )
* * * * THEN
* *openWindows;

Won't work because windows will stay closed due to temperature will
always be under 100 degrees the fault lies with the "or" "||" operator
which was used instead of the "and" (&&) operator.
The code generated: *an infinite loop of never ending numbers that
crashed my computer.

Thank You,

Ray
why did you post this twice?
--
Nick Keighley

Jul 22 '08 #3
Nick Keighley <ni******************@hotmail.comwrites:
On 22 Jul, 06:55, popeyerayaz <popeyera...@gmail.comwrote:

your post is very confusing
>I want run this by the group for correctness.
The question is as follows:

9. Present an example of a logic bug using pseudocode and explain your
answer. (10 points)

Temperature = 70
Â*if (Temperature >69) and (Temperature < 100 )
Â* Â* Â* Â* THEN
Â* Â* openWindows;

else
openLinux

:-)

>Will work because if temperature is higher than 69 degrees and
temperature is lower than 100 degrees windows will open.
2. Gentlemen, after reading your advise [advice?] I had run the code in C++,

what gentlemen? what advice?

>then stated it back in pseudocode. I suppose the programmer could
mistakenly use the "AND" && operator instead of the "OR" || operator
which I found the latter to run a loop which I couldn't end,

how the hell can the above p-code loop??!

>not even
with a ctrl-c, and had to push the power button in to turn off my
computer (please keep that in mind).

I think you need a new computer.
>Also found that the temperatures
reflected would better reflect opening the windows and not closing
them.

what does "temperature reflected" mean? The code you've posted
doesn't close windows.

>Temperature = 70
Â*if (Temperature >69) and (Temperature < 100 )
Â* Â* Â* Â* THEN
Â* Â* openWindows;
Will work because if temperature is higher than 69 degrees and
temperature is lower than 100 degrees windows will open.

why did you post this twice?

>The code generated: numbered list 70-99

what?
Is the sole reason for your reply to be rude, obnoxious and generally
show off? If so, well done. 10/10.
Jul 22 '08 #4
In article <g6**********@registered.motzarella.org>,
Richard <rg****@gmail.comresponded to that jerky Nick Keighley
<ni******************@hotmail.comthusly:
....
>Is the sole reason for your reply to be rude, obnoxious and generally
show off? If so, well done. 10/10.
Of course it is. Is there (quite seriously) any other reason to post to
clc?

(And you should have seen the smile on his face when he did it...)

Jul 22 '08 #5
On Jul 22, 10:55*am, popeyerayaz <popeyera...@gmail.comwrote:
<snip>
You aren't making much sense. Please re-phrase your question in a way
that everyone can understand it. And try posting to the point.
Jul 22 '08 #6
On 22 Jul, 11:55, Richard<rgr...@gmail.comwrote:
Nick Keighley <nick_keighley_nos...@hotmail.comwrites:
On 22 Jul, 06:55, popeyerayaz <popeyera...@gmail.comwrote:
your post is very confusing
I want run this by the group for correctness.
The question is as follows:
9. Present an example of a logic bug using pseudocode and explain your
answer. (10 points)
Temperature = 70
*if (Temperature >69) and (Temperature < 100 )
* * * * THEN
* * openWindows;
else
* * openLinux
:-)
Will work because if temperature is higher than 69 degrees and
temperature is lower than 100 degrees windows will open.
2. Gentlemen, after reading your advise [advice?] I had run the code in C++,
what gentlemen? what advice?
then stated it back in pseudocode. I suppose the programmer could
mistakenly use the "AND" && operator instead of the "OR" || operator
which I found the latter to run a loop which I couldn't end,
how the hell can the above p-code loop??!
not even
with a ctrl-c, and had to push the power button in to turn off my
computer (please keep that in mind).
I think you need a new computer.
Also found that the temperatures
reflected would better reflect opening the windows and not closing
them.
what does "temperature reflected" mean? The code you've posted
doesn't close windows.
Temperature = 70
*if (Temperature >69) and (Temperature < 100 )
* * * * THEN
* * openWindows;
Will work because if temperature is higher than 69 degrees and
temperature is lower than 100 degrees windows will open.
why did you post this twice?
The code generated: numbered list 70-99
what?

Is the sole reason for your reply to be rude, obnoxious and generally
show off? If so, well done. 10/10.- Hide quoted text -
oh course. :-)

if he wants help (I assume that's why he posted to comp.lang.c)
then he's going to have to ask a clear question. His post seemed
to be part of a longer converstation or had been extracted from
another post. I found it unclear. Perhaps if he asked a clear
question he'd get better help. Improving his ability to ask
questions might even make him a better programmer.

What was your reason for posting?
--
Nick Keighley

When it comes to feeding trolls, taking offense at their posts is
like serving them Lobster Thermidor aux Crevettes with Mornay sauce
served in a Provencale manner with shallots and aubergines garnished
with truffle pate, brandy and with a fried egg on top and Spam.
Jul 22 '08 #7
On Jul 22, 2:57 pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
wrote:
<snip reply to troll>
What was your reason for posting?
Trolling.
When it comes to feeding trolls, taking offense at their posts is
like serving them Lobster Thermidor aux Crevettes with Mornay sauce
served in a Provencale manner with shallots and aubergines garnished
with truffle pate, brandy and with a fried egg on top and Spam.
s/taking offense/replying
Jul 23 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
2518
by: Jeff Melvaine | last post by:
I note that I can write expressions like "1 << 100" and the result is stored as a long integer, which means it is stored as an integer of arbitrary length. I may need to use a large number of...
5
3580
by: Mad Scientist Jr | last post by:
Has anyone worked on code that that can parse evaluation expressions (could be numbers or strings) like ( ( "dog" = "dog" ) or "foo" = "bar" ) and ("cow" = "bat" and "bye" = "hi") or ("math" =...
3
4032
by: Lobbo1 | last post by:
Hi, Im a computing student and need help with some pseudocode. The following is what I have got so far... SET point_value = 10 SET suit_value = Hearts SET point_valueA = suit_valueA =...
6
3458
by: Bob Sparks | last post by:
Can some one post an example, or where to find one, using DBINFO in a SQL procedure? I can't seem to find one anywhere. I don't see the linkage between the structure and the SQL language variables...
2
4208
by: david | last post by:
1.I am considering doing a midi file generator for my 4th year project in B.SC. 2.I would do it using c language, but i'm not sure abou t the level of difficulyt involved 3.Basically, the...
4
4601
by: Justine | last post by:
Hi All, I would like to know where & when exactly we would have a need for attributes. A realistic example. Thanz in Advance, Justine
10
1672
by: HK | last post by:
With VB.NET 2005, and a Windows Form, running on a dual CPU box, I need to take a recordset (e.g. 100,000 records) and spawn a thread to handle an internet XML transaction routine for each of the...
2
59063
NeoPa
by: NeoPa | last post by:
CHAPTER 1 - TABLE OF CONTENTS (Including attached database) CHAPTER 2 - INTRODUCTION CHAPTER 3 - TABLE LAYOUT CHAPTER 4 - FORM LAYOUT CHAPTER 5 - FORM MODULE CHAPTER 6 - CODE DISCUSSION (FILTER...
2
3042
by: Joah Senegal | last post by:
Hello all, I;m a beginner C++ and I;m trying to convert some pseudocode into C++. Its pseudo code of the peterson algorithm for N-processes. I almost converted the whole code. But the last...
0
7218
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7307
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.